I'm building a node app in which users are (ideally) able to define styling - for geographic data - using a series of JSON objects:
{
"style":
{
"test": "year",
"condition": "<= 1954 AND >= 1936",
"color": "red"
}
}
In the case above, I like to evaluate that style as
if (year <= 1954 && year >= 1936){
object.color = red;
}
Is there an easy way to parse + evaluate such expressions/build them from such an object? I'm especially interested in letting people string together complex expressions built using <=, >=, ||, && etc.
I'd like to avoid using eval(), if possible.