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

feature request: allocate method #410

Open
NathanC opened this issue Oct 26, 2022 · 1 comment
Open

feature request: allocate method #410

NathanC opened this issue Oct 26, 2022 · 1 comment

Comments

@NathanC
Copy link

NathanC commented Oct 26, 2022

Some other libraries like Dinero.js have an allocate method, similar to distribute but taking percentages or ratios. e.g., `currency(2.00).allocate(50, 25, 25) would result in [1.00, 0.50, 0.50].

This would be a very useful feature! Are there any plans for it? If not, does anyone have a code snippet that does this for currency.js? It's not super hard to implement oneself, which is what I'm doing, but with currency calculation I like to be very careful so any examples are appreciated. The only real complexity is allocating sums that don't nicely distribute over the percentages given.

@scurker
Copy link
Owner

scurker commented Nov 8, 2022

Interesting, I would imagine we could support something similar (as of right now currency.js assumes an equal distribution, and spreads pennies over anything unequal). I'll leave this open to see if anyone else is interested and would provide a proposal on the API.

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

No branches or pull requests

2 participants