source: trip-planner-front/node_modules/lodash/flatMap.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 812 bytes
Line 
1var baseFlatten = require('./_baseFlatten'),
2 map = require('./map');
3
4/**
5 * Creates a flattened array of values by running each element in `collection`
6 * thru `iteratee` and flattening the mapped results. The iteratee is invoked
7 * with three arguments: (value, index|key, collection).
8 *
9 * @static
10 * @memberOf _
11 * @since 4.0.0
12 * @category Collection
13 * @param {Array|Object} collection The collection to iterate over.
14 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
15 * @returns {Array} Returns the new flattened array.
16 * @example
17 *
18 * function duplicate(n) {
19 * return [n, n];
20 * }
21 *
22 * _.flatMap([1, 2], duplicate);
23 * // => [1, 1, 2, 2]
24 */
25function flatMap(collection, iteratee) {
26 return baseFlatten(map(collection, iteratee), 1);
27}
28
29module.exports = flatMap;
Note: See TracBrowser for help on using the repository browser.