chunk
将数组 arr 分割成长度为 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 | | 要分割的数组的元素类型 |
Arguments
| Arg | Type | Optional | Default | Description |
|---|---|---|---|---|
arr | T[] | false | undefined | 要分割的数组 |
length | length | false | undefined | 子数组的长度 |
Returns
| Type |
|---|
T[][] |