mathjs icon indicating copy to clipboard operation
mathjs copied to clipboard

Add `subtractScalar`

Open cshaa opened this issue 3 years ago • 4 comments
trafficstars

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.

cshaa avatar Aug 03 '22 17:08 cshaa

You mean to say "...no subtractScalar method and subtract has matrix as a dependency..." (subtract, not scalar), correct?

gwhitney avatar Aug 03 '22 23:08 gwhitney

Of course! My bad, sorry :) I edited the OP.

cshaa avatar Aug 04 '22 09:08 cshaa

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...

gwhitney avatar Aug 04 '22 16:08 gwhitney

Thanks for bringing this up, I agree that we should extract a subtractScalar function just like we have addScalar, multiplyScalar, and divideScalar.

josdejong avatar Aug 16 '22 14:08 josdejong

I would love to look into this, where can I locate the subtractScalar function? so I can extract it like the other functions.

RenelJean avatar Apr 30 '23 16:04 RenelJean

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.

gwhitney avatar Apr 30 '23 17:04 gwhitney

Implemented now via #3018 and published in v11.12.0.

josdejong avatar Oct 26 '23 08:10 josdejong