visitNode
external fun <TIn : Node?, TVisited : Node?, TOut : Node> visitNode(node: TIn, visitor: Visitor<TIn & Any, TVisited>, test: (node: Node) -> Boolean, lift: (ReadonlyArray<Node>) -> Node = definedExternally): Any(source)(source)
external fun <TIn : Node?, TVisited : Node?> visitNode(node: TIn, visitor: Visitor<TIn & Any, TVisited>, test: (node: Node) -> Boolean = definedExternally, lift: (ReadonlyArray<Node>) -> Node = definedExternally): Any(source)(source)
Visits a Node using the supplied visitor, possibly returning a new Node in its place.
If the input node is undefined, then the output is undefined.
If the visitor returns undefined, then the output is undefined.
If the output node is not undefined, then it will satisfy the test function.
In order to obtain a return type that is more specific than
Node
, a test function must be provided, and that function must be a type predicate.
Parameters
node
The Node to visit.
visitor
The callback used to visit the Node.
test
A callback to execute to verify the Node is valid.
lift
An optional callback to execute to lift a NodeArray into a valid Node.