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: intcomma options #166

Open
lajoiemedia opened this issue Apr 23, 2020 · 1 comment
Open

Feature request: intcomma options #166

lajoiemedia opened this issue Apr 23, 2020 · 1 comment

Comments

@lajoiemedia
Copy link

Some style guides insert commas in numbers only starting at five digits.

10000 => 10,000
but
5000 => 5000

Also, some style guides use spaces instead of commas:

3000000 => 3 000 000

It would be helpful to have options to deal with each case.

@rdmurphy
Copy link
Owner

Hello! 👋

I think the second suggestion is a great one and would be easy enough to add — we could have the separator default to , and allow you to pass in an alternative. (We do however have a separate challenge of intcomma also assuming the radix/cents separator is a period, so that may also need to be an optional parameter.)

The first suggestion I think may be much trickier. Because the functions of journalize are attempting to be compatible with templating languages, having a deep set of options will get hairy, and I also don't want any functions to end up having excessive parameters.

Right now it uses a regex to determine where the separator goes, and it's probably the most core/complicated part of this function. I'd probably recommend that folks grab the intcomma code and customize the regex to their specific needs, or have a second step that wraps what intcomma returns and nudges it into their style.

I worry that anything we could potentially add here would end up being a less rich version of d3-format or Intl.NumberFormat (which intcomma may eventually use itself instead of the regex).

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