1.0.2 • Published 7 months ago

decide-js v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

Simple decision table implementation in JavaScript/TypeScript.

Installation

npm install decide-js

Usage

Example: direct usage

import { decide } from 'decide-js'

const movieGenreDecisionTable = [
  [true, false, false, false, "The Shawshank Redemption"],
  [false, true, true, false, "Shaun of the Dead"],
  [false, true, false, true, "Alien"],
];

const interest = {
  drama: false,
  horror: true,
  comedy: true,
  sciFi: false
}

decide(movieGenreDecisionTable, Object.values(interest)) // => "Shaun of the Dead"

Example: define first, call when needed

import { defineDecisions } from 'decide-js'

// Store the definition somewhere

const movieGenreDecisions = defineDecisions(
[
  [true, false, false, false, "The Shawshank Redemption"],
  [false, true, true, false, "Shaun of the Dead"],
  [false, true, false, true, "Alien"],
]);

// Call when needed

const interest = {
  drama: false,
  horror: true,
  comedy: true,
  sciFi: false
}

movieGenreDecisions.decide(Object.values(interest)) // => "Shaun of the Dead"
1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago