mathjs
mathjs copied to clipboard
Add `subtractScalar`
Right now, there's no subtractScalar method and subtract has matrix as a dependency. This way, it's impossible to make a custom bundle which only contains units and not matrices (which increase the bundle size quite significantly), as Unit depends on subtract and matrix.
You mean to say "...no subtractScalar method and subtract has matrix as a dependency..." (subtract, not scalar), correct?
Of course! My bad, sorry :) I edited the OP.
Excellent point and thanks for the issue report. This issue would be moot with either a TypeScript rewrite of math.js if that's feasible somehow, or a reorganization along the lines of #1975, so in the meantime although I'd be happy to review a PR for it, I at least will be unlikely to generate one...
Thanks for bringing this up, I agree that we should extract a subtractScalar function just like we have addScalar, multiplyScalar, and divideScalar.
I would love to look into this, where can I locate the subtractScalar function? so I can extract it like the other functions.
Well, the point is there currently is no subtractScalar function. The idea of the solution proposed here is to refactor the existing subtract function along the lines that add is currently factored, with an addScalar that can be separately bundled.
Implemented now via #3018 and published in v11.12.0.