Tree
/ API Reference
Tree
/ API Reference

find

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

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

Returns

(T | null) The first node that matches the condition or null if no node matches the condition.

On this page