Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dist/filesize.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,13 @@ function applyNumberFormatting(
if (locale === true) {
result = result.toLocaleString(undefined, localePad);
} else if (locale.length > 0) {
// A string value (e.g. from toPrecision) ignores toLocaleString, so
// coerce it back to a number first to let the locale formatter apply
// its decimal separator (e.g. "1.2" -> "1,2" for sv/de-DE). Zero is
// left as a string so its precision (e.g. "0.00") is retained.
if (typeof result === "string" && Number(result) !== 0) {
result = parseFloat(result);
}
result = result.toLocaleString(locale, { ...localeOptions, ...localePad });
} else {
// Round before separator replacement to ensure excess decimal places
Expand Down
7 changes: 7 additions & 0 deletions dist/filesize.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@ function applyNumberFormatting(
if (locale === true) {
result = result.toLocaleString(undefined, localePad);
} else if (locale.length > 0) {
// A string value (e.g. from toPrecision) ignores toLocaleString, so
// coerce it back to a number first to let the locale formatter apply
// its decimal separator (e.g. "1.2" -> "1,2" for sv/de-DE). Zero is
// left as a string so its precision (e.g. "0.00") is retained.
if (typeof result === "string" && Number(result) !== 0) {
result = parseFloat(result);
}
result = result.toLocaleString(locale, { ...localeOptions, ...localePad });
} else {
// Round before separator replacement to ensure excess decimal places
Expand Down
2 changes: 1 addition & 1 deletion dist/filesize.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/filesize.min.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions dist/filesize.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@ function applyNumberFormatting(
if (locale === true) {
result = result.toLocaleString(undefined, localePad);
} else if (locale.length > 0) {
// A string value (e.g. from toPrecision) ignores toLocaleString, so
// coerce it back to a number first to let the locale formatter apply
// its decimal separator (e.g. "1.2" -> "1,2" for sv/de-DE). Zero is
// left as a string so its precision (e.g. "0.00") is retained.
if (typeof result === "string" && Number(result) !== 0) {
result = parseFloat(result);
}
result = result.toLocaleString(locale, { ...localeOptions, ...localePad });
} else {
// Round before separator replacement to ensure excess decimal places
Expand Down
Loading
Loading