facts-js
v1.0.6
Published
Rules engine
Downloads
6
Readme
FactsJS -- JS Rules Engine
Installation
In browsers:
<script src="facts.js"></script>
Using npm
:
npm i --save facts-js
{sudo} npm i -g facts-js
npm ln facts-js
var FactsJS = require('facts-js');
In an AMD loader:
require(['facts'], function(FactsJS) {
});
Usage
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
Running Tests
gulp test