ast-test
Test source tree on passing some condition.
Use
$ npm install --save ast-test
var parse = parse;var test = ; //catch all `foo` assignmentsvar rule = { if nodeoperator !== '=' return false; return nodeleftname === 'foo'; }; //true //false
API
test(Node, testRules) → Boolean
Test whether node passes test rules passed. testRules
is an object containing node types as keys and testing functions as values. Matched nodes are tested with according testing functions, and if matched none — test returns false. You can declare node supertypes to match, in that case they will be checked beforehead.
var rule = { return true; } { if nodeoperator !== '=' return false; return nodeleftname === 'foo'; }; ; //true; //false; //false