Feature request: intcomma options
lajoiemedia opened this issue · 1 comments
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.
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).