Skip to main content

Function: zipConcur()

zipConcur<Values>(...iterables): ConcurIterable<Values>

Returns a concur iterable that pairs up same-index values, in iteration order, from the given iterables into tuples.

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

WARNING: If one of the concur iterables yields values more quickly than others, then an unbounded number of its values will be buffered so that they can be yielded with the values of other concur iterables at the same index.

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> | ConcurIterable<Values[Key<Key>]> }>

Returns

ConcurIterable<Values>

Example

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

Since

v3.8.0

Defined in

splices.d.ts:1331