UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

28 lines (26 loc) 733 B
import { ArrayMap } from "./internals/types.js"; //#region src/array/flatMap.d.ts /** * `flatMap(array, mapper)` * * Maps each element in `array` using the `mapper` function and flattens the result by one level. * * ```ts * flatMap([1, 2, 3], (x) => [x, x * 2]); // [1, 2, 2, 4, 3, 6] * ``` * * ```ts * pipe( * [1, 2, 3], * flatMap((x) => [x, x * 2]), * ); // [1, 2, 2, 4, 3, 6] * ``` */ declare const flatMap: { <T, U>(mapper: ArrayMap<T, U[]>): (target: T[]) => U[]; <T, U>(mapper: ArrayMap<T, U[]>): (target: readonly T[]) => readonly U[]; <T, U>(target: T[], mapper: ArrayMap<T, U[]>): U[]; <T, U>(target: readonly T[], mapper: ArrayMap<T, U[]>): readonly U[]; }; //#endregion export { flatMap };