Add ability to control number of fractional digits#62
Add ability to control number of fractional digits#62sindresorhus merged 11 commits intosindresorhus:mainfrom
Conversation
26c3b96 to
22b92c7
Compare
|
I can remove fixed option if you don't want it. |
|
What's the use-case for the |
digits and fixed options
|
There was no use case for |
|
It appears the proper way to do this is not through |
8d64572 to
9ddc532
Compare
|
I have tried both ways, in two commits. I think the last commit is the best that has a |
digits and fixed optionsd75314f to
1bbce52
Compare
1bbce52 to
e19c385
Compare
|
I agree with |
|
The default values will be |
c2bd721 to
5640ac7
Compare
|
Actually if you meant default value in the |
|
Requested changes have been made again. |
| @@ -58,7 +58,7 @@ const toLocaleString = (number, locale, options) => { | |||
| let result = number; | |||
There was a problem hiding this comment.
It would be better to just do options = {}.
There was a problem hiding this comment.
Then I would check Object.keys(options).length > 0 in the second if statement?
|
|
||
| if (number < 1) { | ||
| const numberString = toLocaleString(number, options.locale); | ||
| const numberString = toLocaleString(number, options.locale, localeOptions); |
There was a problem hiding this comment.
| const numberString = toLocaleString(number, options.locale, localeOptions); | |
| const numberString = toLocaleString(number, options.locale, { | |
| ...{ | |
| options.minimumFractionDigits, | |
| options.maximumFractionDigits | |
| } | |
| }); |
There was a problem hiding this comment.
localeOptions should be undefined if both minimumFractionDigits and maximumFractionDigits is not set - so that it does not get localized by toLocaleString.
|
Some of the requested changes have been made. |
This should resolve #57.