|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
669 bytes
|
| Line | |
|---|
| 1 | import { ListOfRecursiveArraysOrValues } from '../_internal/ListOfRecursiveArraysOrValues.mjs';
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * Recursively flattens array up to depth times.
|
|---|
| 5 | *
|
|---|
| 6 | * @template T
|
|---|
| 7 | * @param {ArrayLike<T> | null | undefined} array - The array to flatten.
|
|---|
| 8 | * @param {number} [depth=1] - The maximum recursion depth.
|
|---|
| 9 | * @returns {T[]} Returns the new flattened array.
|
|---|
| 10 | *
|
|---|
| 11 | * @example
|
|---|
| 12 | * const array = [1, [2, [3, [4]], 5]];
|
|---|
| 13 | *
|
|---|
| 14 | * flattenDepth(array, 1);
|
|---|
| 15 | * // => [1, 2, [3, [4]], 5]
|
|---|
| 16 | *
|
|---|
| 17 | * flattenDepth(array, 2);
|
|---|
| 18 | * // => [1, 2, 3, [4], 5]
|
|---|
| 19 | */
|
|---|
| 20 | declare function flattenDepth<T>(array: ListOfRecursiveArraysOrValues<T> | null | undefined, depth?: number): T[];
|
|---|
| 21 |
|
|---|
| 22 | export { flattenDepth };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.