-
Notifications
You must be signed in to change notification settings - Fork 1
cycle
Subhajit Sahu edited this page May 17, 2020
·
28 revisions
Gives values that cycle through an iterable. 🏃 [:vhs:] 📦 🌔 📒
iterable.cycle(x, [i], [n]);
// x: an iterable
// i: start index (0)
// n: number of values (-1 => Inf)
const iterable = require('extra-iterable');
var x = [1, 2, 3];
[...iterable.cycle(x, 0, 2)];
// [ 1, 2 ]
[...iterable.cycle(x, 0, 4)];
// [ 1, 2, 3, 1 ]
[...iterable.cycle(x, 1, 6)];
// [ 2, 3, 1, 2, 3, 1 ]