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

flatMapDeep (Functional Programming) es-toolkit

Creates a function that maps each value and deeply flattens the result. Use it with pipe.

const result = pipe(array, flatMapDeep(iteratee));
Info

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

Usage

flatMapDeep calls iteratee for each value in the piped array and recursively flattens the returned arrays.

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

pipe(
  [1, 2],
  flatMapDeep(value => [[value, value]])
); // => [1, 1, 2, 2]

Parameters

iteratee(item: T, index: number) => Urequired

The function that maps each value before deep flattening.

Returns

A function that maps a readonly T[] to a deeply flattened array.

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