🧮 Comparisons
Currently, expressions support =
, >=
, <=
, >
and <
operators. Optionally, you can include a second constructor argument for changing the locale (the default is "en"). Any expressions that do not match a recognized operation get stripped out and are assumed to pass. For simply matching if a property exists, use the =*
expression.
Don't worry about type casting—we'll handle that for you.
const Comparison = require('comparisons');
const tests = ['foo=bar', 'num>=2'];
const stub = { foo: 'bar', num: 3 };
const runner = new Comparison(tests);
runner.eval(stub);
runner.query();