https://github.com/naturalintelligence/bexp
Boolean infix Expression/Notation Parser
https://github.com/naturalintelligence/bexp
Last synced: about 1 month ago
JSON representation
Boolean infix Expression/Notation Parser
- Host: GitHub
- URL: https://github.com/naturalintelligence/bexp
- Owner: NaturalIntelligence
- License: mit
- Created: 2020-06-27T03:27:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-12-23T11:58:17.000Z (over 4 years ago)
- Last Synced: 2024-05-01T11:46:33.288Z (about 2 years ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Boolean Expression Parser (bexp)
```bash
$ npm install bexp
```
```js
const BexpParser = require("bexp");
const options = { allowMathOperators : true};
const bexpParser = new BexpParser("a and b or c but !d", options);
bexpParser.test("a")
bexpParser.test(["a","b"])
```
Supported expressions example
* a and b or c but !d
* a And b Or c But !d
* a AND b OR c BUT !d
* a + b OR c -d
* a + b || c -d
* a - b
* a && b || c !d
* a && b || c !d
Note:
* when operand is not given before `not` then it is considered as AND
* `but` is an alias of `and`.
**Boolean Expressions**
```js
const BexpParser = require("bexp");
const bexpParser = new BexpParser();
bexpParser.evaluate("True and false or true but !N")
```
Supported expressions example
* True and false or true but !N
* True And false Or true But !N
* True AND false OR true BUT not N
* True + false OR true -N
* True + false || true -N
* Yes && false || true !N
* Y && false || true !N
Note:
* when operand is not given before `not` then it is considered as AND
* `but` is an alias of `and`.
## Applications
Use it to evaluate which functional test has to be run when tag expression is given
* @focus
* @All but not @Ignore
Or to build advanced mongodb search queries
* (nodejs or reactjs or angularjs )
* !java
* (sql or mongodb) and (java or nodejs)