Tree
/ API ReferenceTree
/ API ReferencefindAll
Finds all nodes that match a condition.
The Gist
import { findAll } from '@weser/tree'
const nodesWithChildren = findAll(tree, (node) => node.children?.length > 0)
Parameters
| Parameter | Type | Description |
|---|---|---|
| rootNode | T | The root node of the tree. |
| condition | (node: T) => boolean | The condition to match. |
Returns
(Array<T>) An array of nodes that match the condition.
© 2024-present Robin Weser. All Rights Reserved.