LendAndRegret/node_modules/es-toolkit/dist/compat/array/flatMap.js
2026-05-02 17:27:43 +08:00

18 lines
501 B
JavaScript

'use strict';
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const flattenDepth = require('./flattenDepth.js');
const map = require('./map.js');
const isNil = require('../../predicate/isNil.js');
function flatMap(collection, iteratee) {
if (isNil.isNil(collection)) {
return [];
}
const mapped = isNil.isNil(iteratee) ? map.map(collection) : map.map(collection, iteratee);
return flattenDepth.flattenDepth(mapped, 1);
}
exports.flatMap = flatMap;