flatten
Import from @varavel/vdl-plugin-sdk/utils/arrays.
Flattens an array up to the specified depth.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
T |
- | The type of elements within the array. |
D extends number |
1 |
The depth to which the array should be flattened. |
Parameters
| Parameter | Type | Description |
|---|---|---|
arr |
readonly T[] |
The array to flatten. |
depth? |
D |
The depth level specifying how deep a nested array structure should be flattened. Defaults to 1. |
Returns
FlatArray\<T[], D>[]
A new array that has been flattened.