-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
We can make the constructor a lot more robust by removing the value instanceof Decimal
type guard.
The problem with this guard is that you can get false negatives (esp if you end up with different versions of Decimal in your project, for whatever reason). This causes very difficult-to-trace issues where code will throw on valid inputs depending on where the source object was constructed.
The condition probably doesn't need to be quite so restrictive. What if it was replaced with duck-typing? (this could also help in dumping to/from json).
if (typeof value.s == 'number' && typeof value.e == 'number' ... etc )
Metadata
Metadata
Assignees
Labels
No labels