@newdash/newdash
Version:
javascript/typescript utility library
31 lines (30 loc) • 965 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.flattenDeep = void 0;
const baseFlatten_1 = __importDefault(require("./.internal/baseFlatten"));
/** Used as references for various `Number` constants. */
const INFINITY = Infinity;
/**
* Recursively flattens `array`.
*
* @since 5.4.0
* @category Array
* @param array The array to flatten.
* @returns Returns the new flattened array.
* @see [[flatMap]],[[flatMapDeep]],[[flatMapDepth]],[[flatten]],[[flattenDepth]]
* @example
*
* ```js
* flattenDeep([1, [2, [3, [4]], 5]])
* // => [1, 2, 3, 4, 5]
* ```
*/
function flattenDeep(array) {
const length = array == null ? 0 : array.length;
return length ? (0, baseFlatten_1.default)(array, INFINITY) : [];
}
exports.flattenDeep = flattenDeep;
exports.default = flattenDeep;