Skip to content

Module for work with logical expression

Notifications You must be signed in to change notification settings

fortSQ/nodejs-logical-query

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nodejs-logical-query

Build Status

Install and use

npm i nodejs-logical-query -S

where -S - --save / -D - --save-dev

In your code:

let ExpressionParser = require('nodejs-logical-query')

Example

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