-
Notifications
You must be signed in to change notification settings - Fork 133
Usage
Benoit Côté-Jodoin edited this page Jul 2, 2015
·
3 revisions
Call estraverse.traverse or estraverse.replace with an object that has the following methods:
-
enter- Called when entering a node -
leave- Called when leaving a node
Both of these methods have the following signature: function(node, parent).
Note that parent can be null in some situations.
The enter function may control the traversal by returning the
following values (or calling corresponding methods):
-
estraverse.VisitorOption.Skip/this.skip()- Skips walking child nodes of this node. Theleavefunction will still be called. -
estraverse.VisitorOption.Break/this.break()- Ends it all
The leave function can also control the traversal by returning
the following values:
-
estraverse.VisitorOption.Break/this.break()- Ends it all
In estraverse.replace you can also return one of:
-
new node to replace old one with
-
estraverse.VisitorOption.Remove/this.remove()- Removes current node from parent array or replaces withnullif not element of array.