@extra-array/cycle

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

Usage no npm install needed!

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

README

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

Similar: repeat, cycle, rotate, reverse.

This is part of package extra-array.


array.cycle(x, [i], [n]);
// x: an array
// i: start index (0)
// n: number of values (X)
const array = require("extra-array");

var x = [1, 2, 3];
array.cycle(x, 0, 2);
// [ 1, 2 ]

array.cycle(x, 0, 4);
// [ 1, 2, 3, 1 ]

array.cycle(x, 1, 6);
// [ 2, 3, 1, 2, 3, 1 ]


References