JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q18487F
  • License MIT

Creator of decision trees

Package Exports

  • mana.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mana.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

mana.js

Creator of decision trees.

Mana was written to break out the nested decision tree logic from verdict.js. It uses verdict.js as the rule evaluator. This allows "nodes" on the decision tree to contain "children", which implicitly inherit the rules of the parent node.

Installation

npm install mana.js

Usage

var mana = require('mana.js');
var context = {
  var: {
    one: 1
  }
};
var payload = {
  id: 'root',
  children: [
    {
      id: 'Level 1',
      ruleset: {
        composite: 'all',
        rules: [{
          path: 'var.one',
          comparator: 'eq',
          value: 1
        }]
      },
      children: [
        {
          id: 'Level 1.1',
          composite: 'all',
          ruleset: [{
            path: '',
            comparator: 'eq',
            value: ''
          }],
          value: 'I am 1.1'
        },
        {
          id: 'Level 1.2',
          composite: 'any',
          ruleset: [{
            path: '',
            comparator: 'eq',
            value: ''
          }],
          value: 'I am 1.2'
        }
      ]
    }
  ]
};
var tree = mana.parse(payload);
var node = mana.evaluate(context);
console.log(node && node.value);

License

MIT license, whatever