New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v0.5.0 update #7
Conversation
68a32e8
to
9747681
Compare
605e001
to
4e83970
Compare
Hi and thanks for the PR, I have one big issue with it - the removal of the object construction method is a no go.
I am using the code
Where the var is an object pulled from the db, |
Fair enough. My initial though here was that it was just creating a bit of confusion having both signature from a user perspective and from a maintainer perspective since it adds branches to the code. Happy to add the feature back in since the other features could be useful as well. In the future, the lib could temporary be built as 2 bundles using something like webpack to give some time for users to update their code to the 2 arguments-only signature while the feature gets slowly deprecated. Just food for thought 👍 |
Updated the PR and added back support for the object constructor. Brought down the version bump to |
merged. thank you ;) BTW I a considering to add a BigMoney class with the same prototype that could handle arbitrary-precision calculations. |
Do you mean, using something like https://github.com/MikeMcl/big.js ? The library is not crazy large (~2.8kB) but still has a non negligible weight compared to |
yeah something like that, 2.8kb is nothing theese days. |
Because of all the non-backward compatible changes listed below, I figured this update should be treated as a major update.
Changes:
fromDecimal
now accepts integer in case the float turns out to be an integer:Money.fromDecimal(10, Money.EUR)
has an amount of1000
cents.fromDecimal
now accepts decimals as strings:Money.fromDecimal("10.1", Money.EUR)
has an amount of1010
cents.multipliers[0]
infromDecimal
method was0
. Now1
.toJSON
andtoString
methods to allow string concatenation and calls withJSON.stringify
.toDecimal
method to extract the decimal amount as a float (cf. What about toDecimal? #6).divide
andmultiply
method to allow for other functions thanMath.round
.3.x.x
to avoid any API breaking change.v4.2.2
through the.nvmrc
file..editorconfig
file to improve code style consistency across editors.