Tree
/ API Reference
Tree
/ API Reference

findAll

Finds all nodes that match a condition.

The Gist

import { findAll } from '@weser/tree'

const nodesWithChildren = findAll(tree, (node) => node.children?.length > 0)

Parameters

ParameterTypeDescription
rootNodeTThe root node of the tree.
condition(node: T) => booleanThe condition to match.

Returns

(Array<T>) An array of nodes that match the condition.

On this page