chunk
chunk<
T>(params):ChunkResult<T>
Defined in: arrays/chunk/index.ts:22
Splits an array into groups of the given size.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”params
Section titled “params”ChunkParams<T>
The parameters object
Returns
Section titled “Returns”ChunkResult<T>
An array of arrays, each containing at most size elements
Example
Section titled “Example”chunk({ array: [1, 2, 3, 4, 5], size: 2 });// => [[1, 2], [3, 4], [5]]Keywords
Section titled “Keywords”split array, batch, divide, paginate, group by size
Throws
Section titled “Throws”Error if array is not an array
Throws
Section titled “Throws”Error if size is not a positive integer