mathjs
mathjs copied to clipboard
Jhugman math with transform using maps
Followup of #2264: changing mathWithTransform into a LazyMap
This is a work in progress.
- [ ] Test whether the lazy loading actually works as in functions are loaded only when first used
- [ ] Think through whether there are unforeseen edge cases
- [ ] This is a breaking change in the API of
rawFunction: there,mathis now changed fromObjectinto aMap
Does there remain any motivation to change mathWithTransform from a plain object into a new LazyMap object with the Map interface? Or should this PR be closed?
I think we should keep this PR open. I totally forgot about it 😅.
The main reason that we did change scope into a Map was for security and extensibility. I think the main reasons for this PR are similar:
- This PR changes
mathWithTransformfrom being an object with has "lazy" getters into aMapinterface. I think that is less "magic" and easier to grasp. - At the places where we currently use
mathWithTransformwe need to usegetSafePropertyfor security reasons. When having a Map, this is not needed anymore so the attack surface becomes a bit smaller. - A map interface is more flexible, it allows for different implementations and and composing maps (like the
PartitionedMapimplementation)
A downside is that it will be a breaking change: mathWithTransform changes from object to Map.