Skip to main content
cngx-src documentation

walkTree

Functionutils/tree

projects/utils/tree.ts

Description#

DFS visitor. visit is called once per node with the current depth.

Returning the literal false from the visitor stops the walk immediately - no further node is visited at any depth. Any other return value continues the traversal, so existing visitors (void or value-returning arrows alike) keep their behavior. The return type is unknown rather than boolean | void on purpose: a concise arrow like (n) => seen.push(n) must stay assignable.

Signature#

walkTree(nodes, visit)

Parameters#

@paramnodes
@paramvisit

Returns#

void