Skip to main content

Function: walkTree()

function walkTree<T>(
root,
visit,
mode
): T | undefined;

Walks a tree, running the predicate function for each node. If the predicate function returns something other than undefined, then the walk will be stopped and the function will return the returned value.

Type Parameters​

Type ParameterDefault typeDescription
TvoidReturned object type, defaults to void.

Parameters​

ParameterTypeDescription
rootobjectSubtree root object.
visit(node) => T | undefinedFunction that will be run for each node of the tree.
modeWalkTreeModeMode to walk the tree, as defined in WalkTreeMode.

Returns​

T | undefined