Tree
/ API Reference
Tree
/ API Reference

traverse

Traverses a tree and calls a callback function for each node.

The Gist

import { traverse } from '@weser/tree'

traverse(tree, (node) => {
  console.log(node.id)
})

Parameters

ParameterTypeDefaultDescription
rootNodeTThe root node of the tree.
callback(node: T) => voidThe callback function to call for each node.
typetop-down | bottom-uptop-downThe type of traversal to perform.
On this page