Skip to content

chunkAsync

chunkAsync<T>(iterable, size): AsyncIterableIterator<T[]>

Defined in: packages/core/src/iterable/async/chunk.ts:16

Yields consecutive, non-overlapping groups of size items.

The async counterpart of chunk. A final group shorter than size is yielded as-is when the input length is not a multiple of it.

Time complexity: O(n).

T

MaybeAsyncIterable<T>

The input iterable, sync or async.

number

How many items per group. Must be a positive integer.

AsyncIterableIterator<T[]>

An iterator over the groups.

If size is not a positive integer.