ts-prime
Version:
A utility library for JavaScript and Typescript.
27 lines • 942 B
TypeScript
/**
* Map each element of an array using a defined callback function and flatten the mapped result.
* @param array The array to map.
* @param fn The function mapper.
* @signature
* P.flatMap(array, fn)
* @example
* P.flatMap([1, 2, 3], x => [x, x * 10]) // => [1, 10, 2, 20, 3, 30]
* @data_first
* @pipeable
* @category Array
*/
export declare function flatMap<T, K>(array: readonly T[], fn: (input: T) => K | readonly K[]): K[];
/**
* Map each element of an array using a defined callback function and flatten the mapped result.
* @param array The array to map.
* @param fn The function mapper.
* @signature
* P.flatMap(fn)(array)
* @example
* P.pipe([1, 2, 3], P.flatMap(x => [x, x * 10])) // => [1, 10, 2, 20, 3, 30]
* @data_last
* @pipeable
* @category Array
*/
export declare function flatMap<T, K>(fn: (input: T) => K | K[]): (array: readonly T[]) => readonly K[];
//# sourceMappingURL=flatMap.d.ts.map