1.0.1 • Published 2 years ago

@amylas-boolean/api v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

@amylas-boolean/api

presentation

This library aim is to offer boolean operators for the amylas-engine client.

available operators

Here, the new nodes introduced by the library:

true/false

import {AmylasContext} from "@amylas/core"
import AmylasBooleanApi from "@amylas-boolean/api"

const context = new AmylasContext();
const {TRUE, FALSE} = new AmylasBooleanApi(context);

const trueNode = TRUE();    // this node alway evals to true
const falseNode = FALSE();  // this node alway evals to false

and

import {AmylasContext} from "@amylas/core"
import AmylasBooleanApi from "@amylas-boolean/api"

const context = new AmylasContext();
const {TRUE, FALSE, and} = new AmylasBooleanApi(context);

const trueNode = TRUE();
const falseNode = FALSE();
const n1 = and(falseNode, falseNode);           // this node evals to false
const n2 = and(trueNode, falseNode);            // this node evals to false
const n3 = and(falseNode, trueNode);            // this node evals to false
const n4 = and(trueNode, trueNode);             // this node evals to true
const n5 = and(trueNode, trueNode, falseNode);  // this node evals to false
const n6 = and(trueNode, trueNode, trueNode);   // this node evals to true

or

import {AmylasContext} from "@amylas/core"
import AmylasBooleanApi from "@amylas-boolean/api"

const context = new AmylasContext();
const {TRUE, FALSE, or} = new AmylasBooleanApi(context);

const trueNode = TRUE();
const falseNode = FALSE();
const n1 = or(falseNode, falseNode);            // this node evals to false
const n2 = or(trueNode, falseNode);             // this node evals to true
const n3 = or(falseNode, trueNode);             // this node evals to true
const n4 = or(trueNode, trueNode);              // this node evals to true
const n5 = or(trueNode, falseNode, falseNode);  // this node evals to true
const n6 = or(falseNode, falseNode, falseNode); // this node evals to false

xor

import {AmylasContext} from "@amylas/core"
import AmylasBooleanApi from "@amylas-boolean/api"

const context = new AmylasContext();
const {TRUE, FALSE, xor} = new AmylasBooleanApi(context);

const trueNode = TRUE();
const falseNode = FALSE();
const n1 = xor(falseNode, falseNode);   // this node evals to false
const n2 = xor(trueNode, falseNode);    // this node evals to true
const n3 = xor(falseNode, trueNode);    // this node evals to true
const n4 = xor(trueNode, trueNode);     // this node evals to false

not

import {AmylasContext} from "@amylas/core"
import AmylasBooleanApi from "@amylas-boolean/api"

const context = new AmylasContext();
const {TRUE, FALSE, not} = new AmylasBooleanApi(context);

const trueNode = TRUE();
const falseNode = FALSE();
const n1 = not(falseNode);  // this node evals to true
const n2 = not(trueNode);   // this node evals to false

compatibility with other libraries

import {AmylasContext} from "@amylas/core"
import AmylasBooleanApi from "@amylas-boolean/api"
import {AmylasStdApi} from "@amylas-std/api";

const context = new AmylasContext();
const {TRUE, FALSE, not} = new AmylasBooleanApi(context);
const {constant} = new AmylasStdApi(context);

const trueNode = constant(true);
const falseNode = constant(false);
const n1 = not(falseNode); // this node evals to true
const n2 = not(trueNode);  // this node evals to false