json-logic-js-jit
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

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] %

Package Sidebar

Install

npm i json-logic-js-jit

Weekly Downloads

3

Version

0.3.0

License

MIT

Unpacked Size

4.89 kB

Total Files

5

Last publish

Collaborators

  • darrrk