cycle
cycle() function
Returns Iterable/AsyncIterable that infinitely repeats the given Iterable/AsyncIterable
Signature:declare function cycle<A extends Iterable<unknown> | AsyncIterable<unknown>>(iter: A): ReturnIterableIteratorType<A>;
Example
const iter = cycle("abc")
iter.next(); // {value:"a", done: false}
iter.next(); // {value:"b", done: false}
iter.next(); // {value:"c", done: false}
iter.next(); // {value:"a", done: false}
iter.next(); // {value:"b", done: false}
// with pipe
pipe(
cycle([1,2,3,4]),
take(5),
toArray,
); // [1,2,3,4,1]