bullean
v0.0.5
Published
boolean expression interpreter
Downloads
6
Maintainers
Readme
bullean
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.
Support
Submit an issue
Screenshots
Contribute a screenshot
Contributing
Review the guidelines for contributing
License
Jam Risser © 2020
Changelog
Review the changelog
Credits
- Jam Risser - Author
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!