npm i nodejs-logical-query -S
where -S
- --save
/ -D
- --save-dev
In your code:
let ExpressionParser = require('nodejs-logical-query')
Expression: A && !(B || C) || D && !E
Set operand to true/false and define logical query:
let A = true
let B = false
let C = true
let D = true
let E = false
let expressionObject = {
'OR': [
{'AND': [
A,
{'NOT' : {'OR': [B, C]}}
]},
{'AND': [D, {'NOT': E}]}
]
}
And get result:
let expressionParser = new ExpressionParser(expressionObject)
console.log(expressionParser.result) // true