# async-rule-engine

> condition and consequence based rule engine in node

Latest version **0.0.5** (published 2018-01-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install async-rule-engine
pnpm add async-rule-engine
yarn add async-rule-engine
bun add async-rule-engine
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2018-01-23 |
| First published | 2018-01-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Aditya Joshi |
| Maintainers | fuzzy-coder |
| Keywords | rule-engine, flow-api, condition, consequence |

## Links

- npm: https://www.npmjs.com/package/async-rule-engine
- Repository: https://github.com/fuzzy-coder/rule-engine
- Homepage: https://github.com/fuzzy-coder/rule-engine#readme
- Issues: https://github.com/fuzzy-coder/rule-engine/issues
- npm.io page: https://npm.io/package/async-rule-engine

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [node-rules](https://npm.io/package/node-rules.md) ^3.1.0

## Recent versions

- 0.0.5 (latest) — 2018-01-23

## README

# README #

Condition and Consequence based async rule-engine in node.
This package wraps https://github.com/mithunsatheesh/node-rules APIS and enables sync/async support

### What is this repository for? ###

* Provides Scalable flow control API. Prevents developer ending up in callback hell and if else mess.


### How do I get set up? ###

* npm install async-rule-engine

### How do I use api? ###

* create new RuleEngine instance which validates facts against rules.
* use either waterfall or enqueue flow control methods and pass in rules.
* simple rule example :
```javascript
{
  "condition": function(){
      return this.user.type === 'customer'; // condition should rule should return a boolean value. if true consequence will be executed. fact object will be available under this 
  },
  "consequence": function(){
      this.message = 'Hello Customer';
  }
}
```
* Validating facts
```javascript
const engine = new RuleEngine();
engine.waterfall(rules); // list of rules.
engine.validate({'user':{'type': 'customer'}}, function(data){
    console.log(data.message);
});
```

---
_Source: https://npm.io/package/async-rule-engine · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
