Skip to content

cycleAsync

cycleAsync<T>(iterable, times?): AsyncIterableIterator<T>

Defined in: packages/core/src/iterable/async/cycle.ts:19

Yields the whole iterable times times over.

The async counterpart of cycle. 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. Later passes yield from the buffer and never await.

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

T

MaybeAsyncIterable<T>

The input iterable, sync or async.

number = Number.POSITIVE_INFINITY

How many passes to yield. Must be a non-negative integer or Infinity, which repeats forever.

AsyncIterableIterator<T>

An iterator over the repeated elements.

If times is negative, fractional or NaN.