source: trip-planner-front/node_modules/lodash/flattenDepth.js@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 787 bytes
Line 
1var baseFlatten = require('./_baseFlatten'),
2 toInteger = require('./toInteger');
3
4/**
5 * Recursively flatten `array` up to `depth` times.
6 *
7 * @static
8 * @memberOf _
9 * @since 4.4.0
10 * @category Array
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.
14 * @example
15 *
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
33module.exports = flattenDepth;
Note: See TracBrowser for help on using the repository browser.