json-logic-js-jit
Another implementation of JsonLogic, which precompile JSON rules for high speed performance.
Examples
Basic
import { compile } from 'json-logic-js-jit';
const fn = compile({ "and" : [
{ ">" : [3,1] },
{ "<" : [1,3] }
]});
fn(); // true
Add operation
import { compile, addOperation } from 'json-logic-js-jit';
addOperation("plus", (a, b) => a + b);
const fn = compile({ plus: [1, 2] });
fn(); // 3
Pass data
import { compile, addOperation } from 'json-logic-js-jit';
addOperation("var", (key, data) => data[key]);
const fn = compile({ var: ["fruit"] });
fn({ fruit: "apple" }); // "apple"
Built-in operators
- [x] and
- [x] or
- [x] >
- [x] <
- [x] >=
- [x] <=
- [x] ==
- [x] ===
- [x] !=
- [x] !==
- [x] !
- [x] !!
- [x] +
- [x] -
- [x] *
- [x] /
- [x] %