Skip to content

cycle

cycle<T>(iterable, times?): IterableIterator<T>

Defined in: packages/core/src/iterable/cycle.ts:17

Yields the whole iterable times times over.

The source is pulled once and buffered, because an iterator cannot be restarted — so the whole of it is held in memory from the first pass onwards.

Time complexity: O(n × times). Memory: O(n).

T

Iterable<T>

The input iterable.

number = Number.POSITIVE_INFINITY

How many passes to yield. Must be a non-negative integer or Infinity, which repeats forever. Zero yields nothing and consumes nothing.

IterableIterator<T>

An iterator over the repeated elements.

If times is negative, fractional or NaN.