chunk
Splits array arr
into sub-arrays with the length of length
.
Added in v0.0.2
Usage
ts
import { chunk } from 'parsnip-kit'
const arr = [1, 2, 3, 4, 5]
chunk(arr, 2)
// [[1, 2], [3, 4], [5]]
API
Type Parameter
Arg | Type | Description |
---|---|---|
T |
| Type of elements of array to split |
Arguments
Arg | Type | Optional | Default | Description |
---|---|---|---|---|
arr | T[] | false | undefined | The array to split |
length | length | false | undefined | The length of sub-arrays |
Returns
Type |
---|
T[][] |