For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/fp/flattenDeep.md.

flattenDeep (Functional Programming) es-toolkit

Creates a function that recursively flattens nested arrays. Use it with pipe.

const result = pipe(array, flattenDeep());
Info

Prefer the original es-toolkit flattenDeep in ordinary code. Use this fp variant when composing transformations with pipe.

Usage

flattenDeep recursively removes every nested array layer from the piped array. It is lazy-capable inside pipe.

import { flattenDeep, pipe } from 'es-toolkit/fp';

pipe([1, [2, [3, [4]]]], flattenDeep()); // => [1, 2, 3, 4]

Parameters

This function takes no arguments; call it as flattenDeep().

Returns

A function that maps a nested array to a deeply flattened array.

(array: readonly T[]) => Array<ExtractNestedArrayType<T>>
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.