flatMap (Functional Programming) es-toolkit
Creates a function that maps each value to an array and flattens the result by one level. Use it with pipe.
Info
Usage
flatMap calls callback for each value in the piped array and concatenates the returned arrays. It is lazy-capable inside pipe.
Parameters
callback(value: T, index: number) => U[]required
The function that maps each value to an array.
Returns
A function that maps a readonly T[] to a flattened array of callback results.
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.