F

filterInTree

Finds every node in an object graph a predicate matches, depth-first from the root. Cycle-safe.

function filterInTree<T = any>(root: any, predicate: TreePredicate, options?: TreeSearchOptions): T[]

Parameters

NameTypeDescription
rootany

The node to start from; it is tested too.

predicateTreePredicate

Tests each non-nullish node.

options?TreeSearchOptions

Which keys to descend into or skip, and how deep.

Returns

T[]

Every match, in visiting order.