@arrows/array
Version:
Functional tools for JS arrays
23 lines (22 loc) • 676 B
TypeScript
declare type FlatOne = <T>(arr: T[][]) => T[];
declare type _Flat = <T>(depth: number, arr: T[]) => unknown[];
declare type _Flat2 = <T>(depth: number) => (arr: T[]) => unknown[];
declare type CurriedFlat = _Flat & _Flat2;
declare type Flat = CurriedFlat & {
one: FlatOne;
};
/**
* Functional wrapper for Array.prototype.flat with custom depth
*
* Creates a new array with all sub-array elements
* concatenated into it recursively up to the specified depth.
*
* @param depth Maximum recursion depth
* @param arr Initial array
* @returns New array
*
* @method one Version with default depth (1)
*/
declare const flat: Flat;
export { flat };
export default flat;