source: imaps-frontend/node_modules/lodash-es/flatMapDepth.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 899 bytes
Line 
1import baseFlatten from './_baseFlatten.js';
2import map from './map.js';
3import toInteger from './toInteger.js';
4
5/**
6 * This method is like `_.flatMap` except that it recursively flattens the
7 * mapped results up to `depth` times.
8 *
9 * @static
10 * @memberOf _
11 * @since 4.7.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 * @param {number} [depth=1] The maximum recursion depth.
16 * @returns {Array} Returns the new flattened array.
17 * @example
18 *
19 * function duplicate(n) {
20 * return [[[n, n]]];
21 * }
22 *
23 * _.flatMapDepth([1, 2], duplicate, 2);
24 * // => [[1, 1], [2, 2]]
25 */
26function flatMapDepth(collection, iteratee, depth) {
27 depth = depth === undefined ? 1 : toInteger(depth);
28 return baseFlatten(map(collection, iteratee), depth);
29}
30
31export default flatMapDepth;
Note: See TracBrowser for help on using the repository browser.