mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
22 lines
514 B
JavaScript
22 lines
514 B
JavaScript
import baseFlatten from './_baseFlatten';
|
|
|
|
/**
|
|
* This method is like `_.flatten` except that it recursively flattens `array`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to recursively flatten.
|
|
* @returns {Array} Returns the new flattened array.
|
|
* @example
|
|
*
|
|
* _.flattenDeep([1, [2, 3, [4]]]);
|
|
* // => [1, 2, 3, 4]
|
|
*/
|
|
function flattenDeep(array) {
|
|
var length = array ? array.length : 0;
|
|
return length ? baseFlatten(array, true) : [];
|
|
}
|
|
|
|
export default flattenDeep;
|