flatten (Functional Programming) es-toolkit
Creates a function that flattens nested arrays to a given depth. Use it with pipe.
Info
Usage
flatten flattens the piped array up to depth. When depth is omitted, it flattens one level. It is lazy-capable for one-level flattening inside pipe.
Parameters
depthnumber, optionalrequired
The depth to flatten. Defaults to 1.
Returns
A function that maps a nested array to a flattened array.
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.