chunk (Functional Programming) es-toolkit
Creates a function that splits an array into sub-arrays of a given length. Use it with pipe.
Info
Usage
chunk divides an array into sub-arrays, each of length size. When the array cannot be divided evenly, the final chunk holds the remaining elements.
Parameters
sizenumberrequired
The length of each chunk. Must be a positive integer.
Returns
A function that maps a readonly T[] to an array of chunks.
Throws
Throws an error if size is not a positive integer.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.