/walkes

very simple walker for esprima AST

Primary LanguageJavaScript

walker, texas ranger

very simple walker for esprima AST

Build Status Coverage Status Dependency Status

Installation

$ npm install walkes

Usage

walker(esprima.parse("…"), {
	MemberExpression: function (recurse, stop) {
		// the node can be used as `this`
		this.object;
		// you are responsible to call `recurse()` on all the children yourself
		recurse(this.object);
		recurse(this.property);
	},
	default: function (recurse, stop) {
		// call or throw `stop` to completely stop walking.
		stop();
		throw stop;
	}
}, offset);
// when offset is set, will only recurse to nodes that lie within the offset
// esprima option {range: true} needs to be set for this to work

License

LGPLv3