Skip to main content

Function: chunkConcur()

Returns a concur iterable equivalent to concurIterable except its values are grouped into arrays that each contain size values.

The last array in the returned concur iterable will contain fewer than size values (but at least one) if the number of values in concurIterable is not divisible by size.

Throws

if size is not a positive integer.

Example

console.log(
await pipe(
asConcur([1, 2, 3, 4, 5, 6, 7, 8, 9]),
chunkConcur(3),
reduceConcur(toArray()),
),
)
//=> [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]

console.log(
await pipe(
asConcur([`S`, `L`, `O`, `T`, `H`]),
chunkConcur(2),
reduceConcur(toArray()),
),
)
//=> [ [ 'S', 'L' ], [ 'O', 'T' ], [ 'H' ] ]

Since

v2.0.0

Call Signature

chunkConcur<Size>(size): <Value>(concurIterable) => ConcurIterable<Value[]>

Type Parameters

Size extends number

Parameters

size

PositiveInteger<Size>

Returns

Function

Type Parameters

Value

Parameters

concurIterable

ConcurIterable<Value>

Returns

ConcurIterable<Value[]>

Defined in

splices.d.ts:977

Call Signature

chunkConcur<Size, Value>(size, concurIterable): ConcurIterable<Value[]>

Type Parameters

Size extends number

Value

Parameters

size

PositiveInteger<Size>

concurIterable

ConcurIterable<Value>

Returns

ConcurIterable<Value[]>

Defined in

splices.d.ts:980