-
Notifications
You must be signed in to change notification settings - Fork 1
cycle
wolfram77 edited this page Apr 1, 2020
·
28 revisions
Gives values that cycle through an iterable.
iterable.cycle(x, [n]);
// x: an iterable
// n: number of values (-1 => Inf)
const iterable = require('extra-iterable');
var x = [1, 2, 3];
[...iterable.cycle(x, 2)];
// [1, 2]
[...iterable.cycle(x, 4)];
// [1, 2, 3, 1]
[...iterable.cycle(x, 6)];
// [1, 2, 3, 1, 2, 3]