N

utils

namespace utils

Namespaces

Functions

F

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

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

Returns

Every match, in visiting order.

F

findInTree<T = any>(root: any, predicate: TreePredicate, options?: TreeSearchOptions): T | undefined

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

Returns

The first match, or undefined when none matches.

Types

Picks an element: a component name, matched against its displayName or name through memo and forwardRef wrappers (or a host type such as RCTView), or a predicate on the element.

A node in an object graph, such as a React tree. Discord's trees carry no static types, so a predicate reads them unchecked.

Tests one node of a tree; a truthy result is a match.

How a tree search descends.