diginext-utils
Version:
README.md
17 lines • 549 B
TypeScript
/**
* Flattens a nested array by one or more levels.
*
* @template T - The type of elements in the array
* @param array - The array to flatten
* @param depth - The depth level to flatten (default: 1)
* @returns A new flattened array
*
* @example
* ```ts
* flatten([1, [2, 3], [4, 5]]); // [1, 2, 3, 4, 5]
* flatten([1, [2, [3, [4]]]], 2); // [1, 2, 3, [4]]
* flatten([1, [2, [3, [4]]]], Infinity); // [1, 2, 3, 4]
* ```
*/
export declare function flatten<T>(array: unknown[], depth?: number): T[];
//# sourceMappingURL=flatten.d.ts.map