Skip to content

Latest commit

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date

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

varconditioner=require('conditionerjs');//initializing with default optionsvarparser=conditioner({});//Parsing string given valuesvarres=parser.evaluate("a==10",{a:10});// ... Tadaa!console.log(res);//output: true

Options (beta)

All the options must be passed during initialization.

varconditioner=require('conditionerjs');varoptions={}varparser=conditioner(options);// add options here

Todo

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

About

Conditioner, get rid of those tangled conditions

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages