Skip to content
Subhajit Sahu edited this page May 19, 2020 · 20 revisions

Gives values that cycle through array. 🏃 📼 📦 🌔 📒

Similar: [repeat], [cycle].

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

Clone this wiki locally