New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arithmetic Functions work even when not loaded #3200
Comments
Thanks for your input. Missing TypeScript definitions for Can you explain what you try to achieve? If you want to disable specific operators, you could do something like the following:
See docs about |
@josdejong In my case I use:
to create a custom evaluate that should throw an error if the user's input includes any operators. Sure there are workarounds for the issue, mine looks like this:
this way I can mimic the expected behavior (the same as with substract and divide). The issue is not critical and have pretty simple workarounds but it's an issue in the code - the expected behavior is if I create a custom evaluate using only 'evaluateDependencies' all the arithmetic operators should not be imported (surely not partially imported - in this case 'subtract' and 'divide' throw errors and the rest not - 'add', 'multiply', 'pow', and also unaryMinus works when not using 'unaryMinusDependencies'. |
That sounds like you do not need mathjs at all? If the input is just a number you can use JavaScript's |
I oversimplified my use case - I need to support any possible combination of arithmetic functions. One of the cases is not supporting any functions at all as I described above, other cases the user may want only add and subtract, or maybe only multiple and divide, or all functions except log etc. |
In that case I think the best way is to parse the expression into an expression tree and validate this according to the limitations you want to apply, like I explained in #3200 (comment). |
I'm using custom evaluate with only evaluateDependencies but still some of the arithmetic functions are working:
(there may be more arithmetic functions that are working I didn't checked them all)
there is a similar issue: #2876
but there the issue was with 'det' and the suggested solution was to use
require('mathjs/number')
I'm not sure this solution will solve my issue but can't know for sure because mathjs/number missing typescript definitions as described in this open issue:
#2506
The text was updated successfully, but these errors were encountered: