Skip to content

repeatEach

repeatEach<T>(iterable, times): IterableIterator<T>

Defined in: packages/core/src/iterable/repeat-each.ts:16

Yields each element times times in a row before moving to the next.

Not cycle, which repeats the whole sequence rather than each element: repeatEach([1, 2], 2) yields 1, 1, 2, 2 where cycle([1, 2], 2) yields 1, 2, 1, 2.

Time complexity: O(n × times). Nothing is buffered.

T

Iterable<T>

The input iterable.

number

How many times to repeat each element. Must be a non-negative integer; zero yields nothing.

IterableIterator<T>

An iterator over the repeated elements.

If times is not a non-negative integer.