Skip to main content

Variable: zipAsync()

const zipAsync: <Values>(...iterables) => AsyncIterable<Values>

Defined in: splices.d.ts:1296

Returns an async iterable that pairs up same-index values from the given iterables into tuples.

The iterables are iterated in parallel until the shortest one is done, at which point the returned async iterable is done.

Type Parameters

Values

Values extends unknown[] | []

Parameters

iterables

...Readonly<{ [Key in keyof Values]: Iterable<Values[Key]> | AsyncIterable<Values[Key]> }>

Returns

AsyncIterable<Values>

Example

console.log(
await pipe(
zipAsync(
asAsync([1, 2, 3, 4]),
[5, `sloth`, 7],
asAsync([8, 9, 10]),
),
reduceAsync(toArray()),
),
)
//=> [ [ 1, 5, 8 ], [ 2, 'sloth', 9 ], [ 3, 7, 10 ] ]

Since

v3.8.0