# Module: chunk
Creates an array of elements split into subarrays the length of size. If elements can't be split evenly, the final chunk will contain the remaining elements.
import { chunk } from 'utilist';
chunk([0, 1, 2, 3, 4, 5], 4); // returns [[0, 1, 2, 3], [4, 5]]
# Functions
# chunk
▸ chunk‹T›(elements: T[], size: number): T[][]
Defined in src/chunk.ts:19
Type parameters:
▪ T
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
elements | T[] | - | The array to split. |
size | number | 1 | The amount of elements in each subarrays. |
Returns: T[][]