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