Get rid of those tangled conditions
This tiny library has been specifically created to evaluate conditions in a safe and straightfoward way.
You can parse every condition with logical or conditional operators that is normally parsed in javascript (please check 'lib/operators' for a complete list).
Conditions are parsed WITHOUT EVAL, and they are completely safe.
Examples
...
parser.evaluate('a==0 || (b>10 && foo=="bar")',{values})...Install the module:
$ npm install conditionerjs
varconditioner=require('conditionerjs');//initializing with default optionsvarparser=conditioner({});//Parsing string given valuesvarres=parser.evaluate("a==10",{a:10});// ... Tadaa!console.log(res);//output: trueAll the options must be passed during initialization.
varconditioner=require('conditionerjs');varoptions={}varparser=conditioner(options);// add options here- Custom parenthesis support
- Custom operators support
- Adding more operators