facts-js

Rules engine

FactsJS -- JS Rules Engine

In browsers:

<script src="facts.js"></script>

Using npm:

npm i --save facts-js
 
{sudo} npm i -g facts-js
npm ln facts-js

In Node.js & Ringo:

var FactsJS = require('facts-js');

In an AMD loader:

require(['facts'], function(FactsJS) {
 
});
var FactsJS = require('facts-js');
 
rules = new FactsJS.Rules({
    rules: [{
        name: 'x > 2',
        condition: FactsJS.Conditions.gt('x', 2),
        fire: FactsJS.RulesEngine.setFact('y', 10)
    }]
});
 
engine = new FactsJS.RulesEngine({
    rules: rules,
    facts: {
        x: 1, y: 1
    }
});
 
engine.fact('x', 3);
console.log(engine.fact('y')); // should print 10 

gulp test