You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

flattenDeep.js 577B

12345678910111213141516171819202122232425
  1. var baseFlatten = require('./_baseFlatten');
  2. /** Used as references for various `Number` constants. */
  3. var INFINITY = 1 / 0;
  4. /**
  5. * Recursively flattens `array`.
  6. *
  7. * @static
  8. * @memberOf _
  9. * @since 3.0.0
  10. * @category Array
  11. * @param {Array} array The array to flatten.
  12. * @returns {Array} Returns the new flattened array.
  13. * @example
  14. *
  15. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  16. * // => [1, 2, 3, 4, 5]
  17. */
  18. function flattenDeep(array) {
  19. var length = array == null ? 0 : array.length;
  20. return length ? baseFlatten(array, INFINITY) : [];
  21. }
  22. module.exports = flattenDeep;