Urara-Blog/node_modules/.pnpm-store/v3/files/13/fb9aa9bb773d486e032bfdc7fc941d1b160d227d1dcf5647bdb74e5cd9964bb6d73529efe2de694567f12d1ff16f1b5a30807a8a80683ea3cff8591a8f1eba
2022-08-14 01:14:53 +08:00

29 lines
812 B
Text

var baseFlatten = require('./_baseFlatten'),
map = require('./map');
/**
* Creates a flattened array of values by running each element in `collection`
* thru `iteratee` and flattening the mapped results. The iteratee is invoked
* with three arguments: (value, index|key, collection).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new flattened array.
* @example
*
* function duplicate(n) {
* return [n, n];
* }
*
* _.flatMap([1, 2], duplicate);
* // => [1, 1, 2, 2]
*/
function flatMap(collection, iteratee) {
return baseFlatten(map(collection, iteratee), 1);
}
module.exports = flatMap;