Function walkTree

  • 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

    • T = void

    Parameters

    • root: object

      Subtree root object.

    • visit: ((node) => undefined | T)

      Function that will be run for each node of the tree.

        • (node): undefined | T
        • Parameters

          • node: object

          Returns undefined | T

    • mode: WalkTreeMode

      Mode to walk the tree, as defined in WalkTreeMode.

    Returns T | undefined

    Typeparam

    T Returned object type, defaults to void.