basant307/AI_Governance_Project
045
1import baseFlatten from './_baseFlatten.js';2import toInteger from './toInteger.js';3 4/**5 * Recursively flatten `array` up to `depth` times.6 *7 * @static8 * @memberOf _9 * @since 4.4.010 * @category Array11 * @param {Array} array The array to flatten.12 * @param {number} [depth=1] The maximum recursion depth.13 * @returns {Array} Returns the new flattened array.14 * @example15 *16 * var array = [1, [2, [3, [4]], 5]];17 *18 * _.flattenDepth(array, 1);19 * // => [1, 2, [3, [4]], 5]20 *21 * _.flattenDepth(array, 2);22 * // => [1, 2, 3, [4], 5]23 */24function flattenDepth(array, depth) {25 var length = array == null ? 0 : array.length;26 if (!length) {27 return [];28 }29 depth = depth === undefined ? 1 : toInteger(depth);30 return baseFlatten(array, depth);31}32 33export default flattenDepth;34 