# json-logic-js-jit

> Build complex rules, serialize them as JSON, and execute them in JavaScript

Latest version **0.3.0** (published 2021-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-logic-js-jit
pnpm add json-logic-js-jit
yarn add json-logic-js-jit
bun add json-logic-js-jit
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2021-09-26 |
| First published | 2021-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Vladislav Botvin |
| Maintainers | darrrk |
| Keywords | jsonlogic, json, rule, logic, jit |

## Links

- npm: https://www.npmjs.com/package/json-logic-js-jit
- Repository: https://github.com/darky/json-logic-js-jit
- Homepage: https://github.com/darky/json-logic-js-jit#readme
- Issues: https://github.com/darky/json-logic-js-jit/issues
- npm.io page: https://npm.io/package/json-logic-js-jit

## Dependencies (1)

- [map-obj](https://npm.io/package/map-obj.md) 4.3.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.3.0 (latest) — 2021-09-26
- 0.2.0 — 2021-09-26
- 0.1.0 — 2021-09-26

## README

# json-logic-js-jit

Another implementation of [JsonLogic](https://jsonlogic.com), which precompile JSON rules for high speed performance.

## Examples

#### Basic

```js
import { compile } from 'json-logic-js-jit';

const fn = compile({ "and" : [
  { ">" : [3,1] },
  { "<" : [1,3] }
]});

fn(); // true
```

#### Add operation

```js
import { compile, addOperation } from 'json-logic-js-jit';

addOperation("plus", (a, b) => a + b);

const fn = compile({ plus: [1, 2] });

fn(); // 3
```

#### Pass data 

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

---
_Source: https://npm.io/package/json-logic-js-jit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
