Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

flatten-deep

v4.17.11arrow_drop_down
v4.17.11
STATUS
Passing
DOWNLOADS
156
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
A year ago
SIZE
1 KB
Recursively flattens `array`.
1 contributor
Install flatten-deep as a package?
Copied
npm i @bit/lodash.lodash.flatten-deep
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
flattenDeep.js
25 Lines(7 sloc)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import baseFlatten from './_baseFlatten.js';

/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;

/**
 * Recursively flattens `array`.
 *
 * @static
 * @memberOf _
 * @since 3.0.0
 * @category Array
 * @param {Array} array The array to flatten.
 * @returns {Array} Returns the new flattened array.
 * @example
 *
 * _.flattenDeep([1, [2, [3, [4]], 5]]);
 * // => [1, 2, 3, 4, 5]
 */
function flattenDeep(array) {
  var length = array == null ? 0 : array.length;
  return length ? baseFlatten(array, INFINITY) : [];
}

export default flattenDeep;