getChunks()function
getChunks(items: Iterable<T>, size: number): Iterable<readonly T[]>
| Param | Type | |
|---|---|---|
items | Iterable<T> | The iterable to split into chunks. required |
size | number | The maximum number of items per chunk. required |
| Return | |
|---|---|
Iterable<readonly T[]> | An iterable yielding arrays of up to size items. |
Yield chunks of a given size.
- The final chunk may contain fewer than
sizeitems.
Examples
Array.from(getChunks([1, 2, 3, 4, 5], 2)) // [[1, 2], [3, 4], [5]]