Skip to content

MichaelCereda/ConditionerJs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConditionerJs

Get rid of those tangled conditions

What can I do with ConditionerJS?

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

Install the module:

$ npm install conditionerjs

Use

var conditioner = require('conditionerjs');

//initializing with default options
var parser = conditioner({});

//Parsing string given values
var res = parser.evaluate("a==10",{a:10});

// ... Tadaa!
console.log(res);
//output: true

Options (beta)

All the options must be passed during initialization.

var conditioner = require('conditionerjs');

var options = {

}
var parser = conditioner(options); // add options here

Todo

  • Custom parenthesis support
  • Custom operators support
  • Adding more operators

About

Conditioner, get rid of those tangled conditions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published