Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcbachmann/boolean-expression
⋀⋁ Create a boolean expression that's safe (you can still harm your app if you don't validate) to eval.
https://github.com/marcbachmann/boolean-expression
boolean-expression code-generation parser
Last synced: 27 days ago
JSON representation
⋀⋁ Create a boolean expression that's safe (you can still harm your app if you don't validate) to eval.
- Host: GitHub
- URL: https://github.com/marcbachmann/boolean-expression
- Owner: marcbachmann
- Created: 2016-11-22T08:36:31.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T17:58:30.000Z (11 months ago)
- Last Synced: 2024-10-12T18:08:39.407Z (about 1 month ago)
- Topics: boolean-expression, code-generation, parser
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# boolean-expression
Create a boolean expression that's safe to eval
## expression = booleanExpression(exp)
Returns a `BooleanExpression` instance with `toString` and `toTokens` methods.
### expression.toString(map)
```
var expression = booleanExpression('foo AND bar')
var str = expression.toString(function (token) {
return 'val.indexOf(' + JSON.stringify(token) + ')'
})// str == 'val.indexOf("foo") && val.indexOf("bar")'
```
### expression.toTokens()
```
var expression = booleanExpression('foo && bar && !qux')
expression.toTokens()
// returns ['foo', 'bar', 'qux']
```