Skip to content

zip

zip<T>(iterables): IterableIterator<Zipped<T>>

Defined in: packages/core/src/iterable/zip.ts:32

Yields tuples pairing the first element of every iterable, then the second, and so on, stopping as soon as any one of them runs out.

Takes one array rather than a rest parameter, unlike concat: the two shapes cannot be told apart, because an Iterable<T> is very often an array itself.

Every source iterator is closed when iteration ends, whether it ended by exhaustion or because the consumer stopped pulling.

Time complexity: O(1) per tuple, allocating one tuple per yield.

T extends readonly Iterable<unknown, any, any>[]

T

The iterables to advance in lockstep.

IterableIterator<Zipped<T>>

An iterator over the tuples. Empty when no iterables were given.