@extra-iterable/cycle.min

Gives values that cycle through an iterable. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Usage no npm install needed!

<script type="module">
  import extraIterableCycleMin from 'https://cdn.skypack.dev/@extra-iterable/cycle.min';
</script>

README

Gives values that cycle through an iterable. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Similar: repeat, cycle, rotate, reverse.

This is part of package extra-iterable.

This is browserified, minified version of @extra-iterable/cycle.
It is exported as global variable iterable_cycle.
CDN: unpkg, jsDelivr.


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 ]


References