We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Obtain values that cycle through an iterable.
Similar: repeat, cycle, rotate, reverse.
function cycle(x, i, n) // x: an iterable // i: start index [0] // n: number of values [-1 ⇒ Inf]
const xiterable = require('extra-iterable'); var x = [1, 2, 3]; [...xiterable.cycle(x, 0, 2)]; // → [1, 2] [...xiterable.cycle(x, 0, 4)]; // → [1, 2, 3, 1] [...xiterable.cycle(x, 1, 6)]; // → [2, 3, 1, 2, 3, 1]