Skip to content

chunk

chunk<T>(params): ChunkResult<T>

Defined in: arrays/chunk/index.ts:22

Splits an array into groups of the given size.

T

ChunkParams<T>

The parameters object

ChunkResult<T>

An array of arrays, each containing at most size elements

chunk({ array: [1, 2, 3, 4, 5], size: 2 });
// => [[1, 2], [3, 4], [5]]

split array, batch, divide, paginate, group by size

Error if array is not an array

Error if size is not a positive integer