Skip to content

zipAsync

zipAsync<T>(iterables): AsyncIterableIterator<Zipped<T>>

Defined in: packages/core/src/iterable/async/zip.ts:22

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.

The async counterpart of zip. Sources may be mixed, so a materialised array can be paired with a stream. Each round advances every source concurrently rather than one after another, so a round costs the slowest source, not their sum.

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 MaybeAsyncIterable<unknown>[]

T

The iterables to advance in lockstep.

AsyncIterableIterator<Zipped<T>>

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