@arrows/array
Version:
Functional tools for JS arrays
20 lines (19 loc) • 639 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.flatMap = void 0;
const curry_1 = require("@arrows/composition/curry");
const _flatMap = (mappingFn, arr) => arr.flatMap(mappingFn);
/**
* Functional wrapper for Array.prototype.flatMap
*
* Calls a defined mapping function on each element of an array.
* Then, flattens the result into a new array.
* This is identical to a map followed by flat with depth 1.
*
* @param mappingFn Mapping function
* @param arr Initial array
* @returns New array
*/
const flatMap = curry_1.default(_flatMap);
exports.flatMap = flatMap;
exports.default = flatMap;
;