Tree
/ API ReferenceTree
/ API Referenceclone
Clones a node and all its children with new ids.
The Gist
import { clone } from '@weser/tree'
const clonedNode = clone(tree, 'node-id')
Parameters
| Parameter | Type | Description |
|---|---|---|
| rootNode | T | The root node of the tree. |
| id | string | The id of the node to clone. |
Returns
(T | null) A new node with the same structure as the original node, but with a new id. Returns null if no node with the given id was found.
© 2024-present Robin Weser. All Rights Reserved.