Skip to content
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

Proposal: make the interface expect Dollars #3

Open
brycefisher opened this issue Dec 9, 2016 · 2 comments
Open

Proposal: make the interface expect Dollars #3

brycefisher opened this issue Dec 9, 2016 · 2 comments

Comments

@brycefisher
Copy link

brycefisher commented Dec 9, 2016

In the handful of places I've personally used this module, I've nearly always been starting from and ending with dollars, not cents. I imagine that many others who use this feel the same way?

My proposal would be to change from this kind of usage:

Cents = require 'goodeggs-money'
price = Cents.fromDollars(15.99).plus(Cents.fromDollarys(1.60)).toDollars()

to something like this:

Dollars = require 'goodeggs-money' # or maybe require('goodeggs-money').Dollars for a nonbreaking change
price = Dollars(15.99).plus(1.60).toNumber()

Haven't thought too deeply about the implementation of this change, but it feels like the API I would want.

For what it's worth, this is much closer to API for the currency.js module that I quite like.

Thoughts?

@sylspren
Copy link

sylspren commented Dec 9, 2016

fwiw I prefer cents to avoid thinking about number precision. Cents are the lowest unit we can track and its easy to see you are using it correctly - pass in an integral amount.

@asalant
Copy link

asalant commented Dec 9, 2016 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants