0.1.1 • Published 12 months ago

@bxr1ng-os/boolean-evaluator v0.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

Boolean evaluator

Known Vulnerabilities NPM Downloads NPM License npm Codecov

Package for transforming a string with logical operators into the result of an expression.

Installation

$ npm install @bxr1ng-os/boolean-evaluator

Usage

import Evaluate from "@bxr1ng-os/boolean-evaluator";

const string = "!(true || false) && true";

const result = Evaluate(string);

console.log(result); // false

You can also pass your variables to the function. Simply write your variables in a string, and pass in the second parameter an object with the values.

import Evaluate from "@bxr1ng-os/boolean-evaluator";

const newValues = { "some-true-value": true, "some-false-value": false};
const string = "some-true-value || some-false-value";

const result = Evaluate(string, newValues);

console.log(result); // true

Available operators and values

&&, ||, !, (, ), true, false

NOTE: Default values cannot be reassigned!

License

ISC

Author

Danya Voshchuk (vochshukdaniil@gmail.com)

0.1.1

12 months ago

0.1.0

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago