-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
Add ability to control number of fractional digits #62
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to just do options = {}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const numberString = toLocaleString(number, options.locale, localeOptions); | |
const numberString = toLocaleString(number, options.locale, { | |
...{ | |
options.minimumFractionDigits, | |
options.maximumFractionDigits | |
} | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.