Tree
/ API ReferenceTree
/ API Referencefind
Finds the first node that matches a condition.
The Gist
import { find } from '@weser/tree'
const node = find(tree, (node) => node.id === 'node-id')
Parameters
| Parameter | Type | Description |
|---|---|---|
| rootNode | T | The root node of the tree. |
| condition | (node: T) => boolean | The condition to match. |
Returns
(T | null) The first node that matches the condition or null if no node matches the condition.
© 2024-present Robin Weser. All Rights Reserved.