silentmatt / expr-eval

Mathematical expression evaluator in JavaScript
http://silentmatt.com/javascript-expression-evaluator/
MIT License
1.19k stars 239 forks source link

Add CHANGELOG.md - breaking changes #209

Closed iongion closed 5 years ago

iongion commented 5 years ago

This morning I've upgraded from the 1.x series and for some unknown reasons, things are now broken. Can you do something to avoid this by mentioning changes in a file and releasing them together with the version & tag bump ?

silentmatt commented 5 years ago

Thanks, I intended to write something up, and definitely should have. I added one now, that should cover anything that could break existing code.

The most likely reason something could break is I removed the if function, which is replaced by the ternary x ? a : b operator. If you still need it, you can add it back by adding your own implementation to the parser.functions object:

var parser = new Parser();
parser.functions['if'] = function (condition, trueValue, falseValue) {
     return condition ? trueValue : falseValue;
};

The other likely reason is that you're defining a custom function that conflicts with one of the new operators, which you could fix by either changing your name to remove the conflict, or disabling the operator.

The other changes shouldn't break existing code, because they use new syntax that wouldn't have worked in the 1.x versions. So if it's something else that broke, there might be a bug that I'll need to fix.