mapDeep() function
Creates a new array using a depth-first traversal Map function (supports continue and break operations). Can be used for inserting or removing tree items.
Can traverse any array-like object with a length property and numeric keys.
Signature:
typescript
export declare function mapDeep<V>(tree: ArrayLike<V>, iteratee: (val: V, index: number, currentArr: ArrayLike<V>, tree: ArrayLike<V>, parent: V | null, level: number) => {
[k: string | number]: any;
} | boolean, options?: {
childField?: string;
reverse?: boolean;
}): any[];Parameters
Parameter | Type | Description |
|---|---|---|
tree |
| Tree data |
iteratee | (val: V, index: number, currentArr: | Iteratee function. Returns true to continue, false to break. |
options | { childField?: string; reverse?: boolean; } | (Optional) Options to customize child element name, reverse traversal. Default: { childField: 'children', reverse: false, } |
Returns:
any[]
{any[]} A new tree structure