currency.js
currency.js copied to clipboard
Add a .inCents() function
If you need to access the underlying value in cents (for instance to persist to a database or use in an API call), currently you need to use:
currency(valueInDollars).intValue;
It would be slightly more clear to be able to use:
currency(valueInDollars).inCents();
Not sure if inCents()
is the best naming; could also consider toCentValue()
, centValue()
, valueInCents()
, etc
'subUnits' might be better to help remove api references to the US dollar/cents.
How about currency(valueInMajorUnits).minorUnits
?
If you had a precision
> 2, then currency(valueInDollars).intValue
would not equal cents either.