This is a logical expression parser for JavaScript, it can parse a logical expression into a AST object and evaluates the result using your token checking function.
|Or&And!Not()Parentheses
- The parser parse and tokenize the expression, for example one of your function requires
REGISTED&(SPECIAL|INVITED) - Parser then will pass
REGISTED,SPECIALandINVITEDinto your token checking function to get a boolean result - Finaly the parser will evaluates the final result
constLEP=require('logical-expression-parser');constREQUIREMENTS='REGISTED&(SPECIAL|INVITED)';constLIST_A=['REGISTED','INVITED'];constLIST_B=['SPECIAL','EXPERT'];constRESULT_A=LEP.parse(REQUIREMENTS,t=>LIST_A.indexOf(t)>-1);constRESULT_B=LEP.parse(REQUIREMENTS,t=>LIST_B.indexOf(t)>-1);// RESULT_A: true// RESULT_B: false