Function: zipAsync()
zipAsync<
Values
>(...iterables
):AsyncIterable
<Values
,any
,any
>
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 extends [] | unknown
[]
Parameters
iterables
...Readonly
<{ [Key in string | number | symbol]: Iterable<Values[Key<Key>], any, any> | AsyncIterable<Values[Key<Key>], any, any> }>
Returns
AsyncIterable
<Values
, any
, any
>
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