-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
build: upgrade and migrate to Dinero.js v2 #1030
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3715,6 +3715,25 @@ | |
enabled "2.0.x" | ||
kuler "^2.0.0" | ||
|
||
"@dinero.js/[email protected]": | ||
version "2.0.0-alpha.6" | ||
resolved "https://registry.yarnpkg.com/@dinero.js/calculator-number/-/calculator-number-2.0.0-alpha.6.tgz#9ed3d733a7914b283e41be05005d2d6512145032" | ||
integrity sha512-+nTAemUcZMYvwYQ4s8xn3SlIQPJtz6UD97rs9BMAK4vXTihFIrxlDDiJIXwUgFsSJ/SfNLaVgYAEVNhCratO/w== | ||
dependencies: | ||
"@dinero.js/core" "2.0.0-alpha.6" | ||
|
||
"@dinero.js/[email protected]": | ||
version "2.0.0-alpha.6" | ||
resolved "https://registry.yarnpkg.com/@dinero.js/core/-/core-2.0.0-alpha.6.tgz#d8554033125a9bbc72a3ca98a68363c8b339d293" | ||
integrity sha512-AJxNGi9a9+y1Ow2RR4KAGpWxhrrIgtHFkAQOVJOaWT2Js7TcAEWPgyubE4RBKSN0lgS2sMkeB8FfUbaO7Sphdw== | ||
dependencies: | ||
"@dinero.js/currencies" "2.0.0-alpha.6" | ||
|
||
"@dinero.js/[email protected]": | ||
version "2.0.0-alpha.6" | ||
resolved "https://registry.yarnpkg.com/@dinero.js/currencies/-/currencies-2.0.0-alpha.6.tgz#4dc9aea3b32e9eab8cc8bb3a0b3102e9ad876a89" | ||
integrity sha512-MLvmLF7B82ntGT3y/qxWga7VTUi/bmfj0e8RxcpphkmzT2qBtmn0fabqf+bSkpLn5Xbnz2yOXo8LAJHul94XpA== | ||
|
||
"@emotion/hash@^0.8.0": | ||
version "0.8.0" | ||
resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.8.0.tgz#bbbff68978fefdbe68ccb533bc8cbe1d1afb5413" | ||
|
@@ -8732,10 +8751,14 @@ dijkstrajs@^1.0.1: | |
resolved "https://registry.yarnpkg.com/dijkstrajs/-/dijkstrajs-1.0.1.tgz#d3cd81221e3ea40742cfcde556d4e99e98ddc71b" | ||
integrity sha1-082BIh4+pAdCz83lVtTpnpjdxxs= | ||
|
||
[email protected]: | ||
version "1.8.1" | ||
resolved "https://registry.yarnpkg.com/dinero.js/-/dinero.js-1.8.1.tgz#775a647629b4195af9d02f46e9b7fa1fd81e906d" | ||
integrity sha512-AQ09MDKonkGUrhBZZFx4tPTVcVJuHJ0VEA73LvcBoBB2eQSi1DbapeXj4wnUUpx1hVnPdyev1xPNnNMGy/Au0g== | ||
[email protected]: | ||
version "2.0.0-alpha.6" | ||
resolved "https://registry.yarnpkg.com/dinero.js/-/dinero.js-2.0.0-alpha.6.tgz#eb22e2e7a6e8d7796838b9ad60f0d5a23db1add4" | ||
integrity sha512-rKU2w5AATj7SlPCIAErjuC5iGBW+dM/jes1Sl0loOWlBFIEUbBCcAvk9wLM1/Wg87YbktWdEd+sgTdPxLrA0NA== | ||
dependencies: | ||
"@dinero.js/calculator-number" "2.0.0-alpha.6" | ||
"@dinero.js/core" "2.0.0-alpha.6" | ||
"@dinero.js/currencies" "2.0.0-alpha.6" | ||
|
||
dir-glob@^3.0.1: | ||
version "3.0.1" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarahdayan I see that Dinero v2 is in alpha and I'd like to provide some feedback around this DX.
While the flexibility for this
format
method is great, I'm wondering why the need to define such a large callback around a given currency? This DX feels a bit unintuitive and for a currency's "default", I would expect the library to handle this for me. Have you've considered including default helpers such as this or simplifying this piece for v2?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @kevinold and thanks for the feedback!
You're right, the flexibility comes at the expense of simplicity here. I'm currently rethinking this function for several other reasons, and providing a default return value is part of the thinking process.
The main reason why picking a default is difficult is that Dinero also handles non-decimal currencies. While it might make sense to return "USD 10.50" by default for
dinero({ amount: 1050, currency: USD })
, there's no good option when passing non-decimal objects. More context in this issue.I've reworked things and now should be able to expose enough information to
toFormat
to make formatting easier.