@newdash/newdash
Version:
javascript/typescript utility library
24 lines (23 loc) • 586 B
TypeScript
/**
* Recursively flatten `array` up to `depth` times.
*
* @since 5.4.0
* @category Array
* @param array The array to flatten.
* @param depth The maximum recursion depth.
* @returns Returns the new flattened array.
* @see [[flatMap]],[[flatMapDeep]],[[flatMapDepth]],[[flattenDeep]]
* @example
*
* ```js
* const array = [1, [2, [3, [4]], 5]]
*
* flattenDepth(array, 1)
* // => [1, 2, [3, [4]], 5]
*
* flattenDepth(array, 2)
* // => [1, 2, 3, [4], 5]
* ```
*/
declare function flattenDepth(array: Array<any>, depth?: number): Array<any>;
export default flattenDepth;