1aaf28c4bc793eed7fcf0311e4f521970f52446a
[yaffs-website] / node_modules / grunt-legacy-log-utils / node_modules / lodash / flatMap.js
1 var baseFlatten = require('./_baseFlatten'),
2     map = require('./map');
3
4 /**
5  * Creates an array of flattened values by running each element in `collection`
6  * through `iteratee` and concating its result to the other mapped values.
7  * The iteratee is invoked with three arguments: (value, index|key, collection).
8  *
9  * @static
10  * @memberOf _
11  * @category Collection
12  * @param {Array|Object} collection The collection to iterate over.
13  * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration.
14  * @returns {Array} Returns the new flattened array.
15  * @example
16  *
17  * function duplicate(n) {
18  *   return [n, n];
19  * }
20  *
21  * _.flatMap([1, 2], duplicate);
22  * // => [1, 1, 2, 2]
23  */
24 function flatMap(collection, iteratee) {
25   return baseFlatten(map(collection, iteratee));
26 }
27
28 module.exports = flatMap;