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
20 changes: 12 additions & 8 deletions dist/filesize.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 11.0.21
* @version 11.0.22
*/
'use strict';

Expand Down Expand Up @@ -475,6 +475,16 @@ function decorateResult(
result[1] = symbols[result[1]];
}

// Capture the numeric value before formatting; a comma decimal separator
// (via separator or a locale such as de-DE) would otherwise make parseFloat
// read "1,5" as 1 and select the singular unit name.
let numericValue;
if (typeof result[0] === "string") {
numericValue = parseFloat(result[0]);
} else {
numericValue = result[0];
}

result[0] = applyNumberFormatting(
result[0],
locale,
Expand All @@ -492,15 +502,9 @@ function decorateResult(
} else {
unit = BYTE;
}
let val;
if (typeof result[0] === "string") {
val = parseFloat(result[0]);
} else {
val = result[0];
}
// Determine singular/plural suffix
let suffix;
if (val === 1) {
if (numericValue === 1) {
suffix = EMPTY;
} else {
suffix = S;
Expand Down
20 changes: 12 additions & 8 deletions dist/filesize.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 11.0.21
* @version 11.0.22
*/
// Error Messages
const INVALID_NUMBER = "Invalid number";
Expand Down Expand Up @@ -471,6 +471,16 @@ function decorateResult(
result[1] = symbols[result[1]];
}

// Capture the numeric value before formatting; a comma decimal separator
// (via separator or a locale such as de-DE) would otherwise make parseFloat
// read "1,5" as 1 and select the singular unit name.
let numericValue;
if (typeof result[0] === "string") {
numericValue = parseFloat(result[0]);
} else {
numericValue = result[0];
}

result[0] = applyNumberFormatting(
result[0],
locale,
Expand All @@ -488,15 +498,9 @@ function decorateResult(
} else {
unit = BYTE;
}
let val;
if (typeof result[0] === "string") {
val = parseFloat(result[0]);
} else {
val = result[0];
}
// Determine singular/plural suffix
let suffix;
if (val === 1) {
if (numericValue === 1) {
suffix = EMPTY;
} else {
suffix = S;
Expand Down
4 changes: 2 additions & 2 deletions 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.

20 changes: 12 additions & 8 deletions dist/filesize.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 11.0.21
* @version 11.0.22
*/
(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports):typeof define==='function'&&define.amd?define(['exports'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.filesize={}));})(this,(function(exports){'use strict';// Error Messages
const INVALID_NUMBER = "Invalid number";
Expand Down Expand Up @@ -471,6 +471,16 @@ function decorateResult(
result[1] = symbols[result[1]];
}

// Capture the numeric value before formatting; a comma decimal separator
// (via separator or a locale such as de-DE) would otherwise make parseFloat
// read "1,5" as 1 and select the singular unit name.
let numericValue;
if (typeof result[0] === "string") {
numericValue = parseFloat(result[0]);
} else {
numericValue = result[0];
}

result[0] = applyNumberFormatting(
result[0],
locale,
Expand All @@ -488,15 +498,9 @@ function decorateResult(
} else {
unit = BYTE;
}
let val;
if (typeof result[0] === "string") {
val = parseFloat(result[0]);
} else {
val = result[0];
}
// Determine singular/plural suffix
let suffix;
if (val === 1) {
if (numericValue === 1) {
suffix = EMPTY;
} else {
suffix = S;
Expand Down
Loading
Loading