Intro
deep-selectors provides a really simple DSL and its really fast parser that return an array of test functions for traversal methods.
Both traversal methods accept as second argument a string selector. It will be parsed before use in traversal.
Warning For the moment it use dynamic function (aka new Function(...)) and so could not be runned under paranoiac environnements (as Adobe Air). More work will be done on it in a close future.
example
var r = deep.depthFirst({
a:{
b:12
},
c:{
b:14
},
d:{
e:{
f:true,
g:"hello"
},
h:{
f:false,
g:"world"
}
}
}, "b=12 | (f&g)");
deep.log(deep.utils.nodes.paths(r));
syntax
As simple as if you where typing it in JavaScript. But :
- Simple "=" for equality test.
- Simple "&" for conjonction.
- Simple "|" for disjonction.
- You could use any valid parenthesis block.
- No >, >=, <, <= for the moment.
- Use 'this' to test value itself e.g. "this=12".