0.1.0 • Published 9 years ago
decision-tree-eval v0.1.0
The package exports a single function of two arguments
A Decision Tree object
An object with key-value pairs of variables used in decision tree conditions
that returns a value.
var evaluate = require('decision-tree-eval')
var assert = require('assert')
assert.equal(
evaluate(
{ condition: 'English',
true: { result: 'Hello!' },
false: { result: 'Allo!' } },
{ English: true }),
'Hello!')
assert.equal(
evaluate(
{ condition: 'English',
true: { result: 'Hello!' },
false: { result: 'Allo!' } },
{ English: false }),
'Allo!')
assert.equal(
evaluate(
{ condition: { or: [ 'USA', 'UK' ] },
true: { result: 'Hello!' },
false: { result: 'Allo!' } },
{ USA: true }),
'Hello!')
0.1.0
9 years ago