1 var baseFlatten = require('./_baseFlatten'),
2 toInteger = require('./toInteger');
5 * Recursively flatten `array` up to `depth` times.
11 * @param {Array} array The array to flatten.
12 * @param {number} [depth=1] The maximum recursion depth.
13 * @returns {Array} Returns the new flattened array.
16 * var array = [1, [2, [3, [4]], 5]];
18 * _.flattenDepth(array, 1);
19 * // => [1, 2, [3, [4]], 5]
21 * _.flattenDepth(array, 2);
22 * // => [1, 2, 3, [4], 5]
24 function flattenDepth(array, depth) {
25 var length = array == null ? 0 : array.length;
29 depth = depth === undefined ? 1 : toInteger(depth);
30 return baseFlatten(array, depth);
33 module.exports = flattenDepth;