Skip to content

clayrisser/bullean

Repository files navigation

bullean

GitHub stars

boolean expression interpreter

Please ★ this repo if you found it useful ★ ★ ★

This is based on the rancher catalog app show_if question variable. You can read more about it at the link below.

https://rancher.com/docs/rancher/v2.x/en/helm-charts/legacy-catalogs/creating-apps/#question-variable-reference

Features

  • parentheses support
  • support for order of operations

Installation

npm install --save bullean

Dependencies

Usage

import Bullean from 'bullean';

const bullean = new Bullean({
  hello: 'world',
  howdy: 'texas'
});
console.log(bullean.eval('hello=world||howdy=world')); // true
console.log(bullean.eval('hello=world&&howdy=world')); // false
import Bullean from 'bullean';

const bullean = new Bullean();
const ast = bullean.parse('hello=world&&howdy=texas');
console.log(JSON.stringify(ast, null, 2));

This will output the following AST.

{
  "operator": "and",
  "predicates": [
    {
      "operator": "=",
      "left": {
        "name": "hello",
        "type": "identifier"
      },
      "value": "world"
    },
    {
      "operator": "=",
      "left": {
        "name": "howdy",
        "type": "identifier"
      },
      "value": "texas"
    }
  ]
}

You can find more examples in the tests at the link below.

src/bullean.spec.ts

Support

Submit an issue

Screenshots

Contribute a screenshot

Contributing

Review the guidelines for contributing

License

MIT License

Jam Risser © 2020

Changelog

Review the changelog

Credits

Support on Liberapay

A ridiculous amount of coffee ☕ ☕ ☕ was consumed in the process of building this project.

Add some fuel if you'd like to keep me going!

Liberapay receiving Liberapay patrons

About

boolean expression interpreter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published