1 var baseFlatten = require('./_baseFlatten'),
2 map = require('./map'),
3 toInteger = require('./toInteger');
6 * This method is like `_.flatMap` except that it recursively flattens the
7 * mapped results up to `depth` times.
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.
19 * function duplicate(n) {
23 * _.flatMapDepth([1, 2], duplicate, 2);
24 * // => [[1, 1], [2, 2]]
26 function flatMapDepth(collection, iteratee, depth) {
27 depth = depth === undefined ? 1 : toInteger(depth);
28 return baseFlatten(map(collection, iteratee), depth);
31 module.exports = flatMapDepth;