I'm writing a program that needs to evaluate a large number of different boolean expressions that are determined at runtime by information I read in from my datasource at runtime.
Is it possible to construct such a function in javascript?
My potential workarounds are to construct a string of boolean expressions that could be converted into a working boolean expression. The names of the variables are predetermined so this could be feasible if I knew how to do this, but I don't. Another option would be to run this dynamic boolean expression generating process concurrently with the function I use to read in data, but this would greatly increase the complexity of my program, so I would like to avoid this if possible.
Here are some examples:
Again, my variable names are predefined: let's call them numVar1, numVar2, boolVar for clarity.
Each of these dynamic boolean expressions would be composed of and, or, and not operations like this:
numVar1 > 0 && numVar2 < 0
numVar1 > 1 && !(numVar2 < 2)
numVar2 > 2 || (numVar1 < 100 && (boolVar === true))
each function would have these three parameters and one such boolean expression, but the actual expression would need to be generated from a JSON datafile that I parse myself.