chunkBy (Functional Programming) es-toolkit
Creates a function that splits adjacent values whenever a key changes. Use it with pipe.
Info
This helper is specific to es-toolkit/fp. Use it when you want this operation as part of a pipe pipeline.
Usage
chunkBy walks the piped array from left to right and groups adjacent values while iteratee returns the same key. A new chunk starts when the key changes.
Parameters
iteratee(value: T) => unknownrequired
The function that returns the grouping key for each value.
Returns
A function that maps a readonly T[] to chunks of adjacent values.
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.