Skip to content

Commit 6d6625e

Browse files
authored
chore: release v11.0.35 (#424)
1 parent a3e689c commit 6d6625e

10 files changed

Lines changed: 54 additions & 21 deletions

‎CHANGELOG.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@ All notable changes to this project will be documented in this file. Dates are d
44

55
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
66

7+
#### [11.0.35](https://github.com/avoidwork/filesize.js/compare/11.0.34...11.0.35)
8+
9+
- fix: format a negative value that rounds to zero like any other zero [`#423`](https://github.com/avoidwork/filesize.js/pull/423)
10+
- chore(deps-dev): bump rollup from 4.68.2 to 4.68.3 [`#421`](https://github.com/avoidwork/filesize.js/pull/421)
11+
- fix: format a negative value that rounds to zero like any other zero (#423) [`#422`](https://github.com/avoidwork/filesize.js/issues/422)
12+
713
#### [11.0.34](https://github.com/avoidwork/filesize.js/compare/11.0.33...11.0.34)
814

15+
> 16 November 2026
16+
17+
- chore: release v11.0.34 [`#420`](https://github.com/avoidwork/filesize.js/pull/420)
918
- fix: prevent scientific notation leak in precision output [`#419`](https://github.com/avoidwork/filesize.js/pull/419)
1019

1120
#### [11.0.33](https://github.com/avoidwork/filesize.js/compare/11.0.32...11.0.33)

‎dist/filesize.cjs‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
55
* @license BSD-3-Clause
6-
* @version 11.0.34
6+
* @version 11.0.35
77
*/
88
'use strict';
99

@@ -402,6 +402,11 @@ function applyNumberFormatting(
402402
) {
403403
let result = value;
404404

405+
// decorateResult passes a negative value that rounds to zero as "-0" so its
406+
// sign survives. It must still get the locale, padding and separator that
407+
// any other zero gets.
408+
const negativeZero = result === "-0";
409+
405410
// When padding alongside a locale, let the locale formatter emit the fixed
406411
// number of fraction digits. The manual string padding below cannot tell a
407412
// locale-inserted grouping separator from the decimal separator, so it
@@ -410,11 +415,12 @@ function applyNumberFormatting(
410415
pad && round > 0 ? { minimumFractionDigits: round, maximumFractionDigits: round } : undefined;
411416

412417
// Strings from toPrecision ignore toLocaleString; preserve zero strings
413-
// so their precision (e.g. "0.00") is retained.
418+
// so their precision (e.g. "0.00") is retained. "-0" becomes the number -0,
419+
// which the locale formatter prints with its own minus sign.
414420
if (
415421
(locale === true || locale.length > 0) &&
416422
typeof result === "string" &&
417-
Number(result) !== 0
423+
(Number(result) !== 0 || negativeZero)
418424
) {
419425
result = parseFloat(result);
420426
}
@@ -427,7 +433,9 @@ function applyNumberFormatting(
427433
} else {
428434
// Round before separator replacement to ensure excess decimal places
429435
// are truncated when pad is also set (fixes padding + separator bug).
430-
if (separator.length > 0 && pad && round > 0) {
436+
// Skipped for "-0": the arithmetic would turn it into -0, whose string
437+
// form "0" drops the sign.
438+
if (separator.length > 0 && pad && round > 0 && !negativeZero) {
431439
const p = Math.pow(10, round);
432440
result = roundingFunc(result * p) / p;
433441
}

‎dist/filesize.js‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
55
* @license BSD-3-Clause
6-
* @version 11.0.34
6+
* @version 11.0.35
77
*/
88
// Error Messages
99
const INVALID_NUMBER = "Invalid number";
@@ -398,6 +398,11 @@ function applyNumberFormatting(
398398
) {
399399
let result = value;
400400

401+
// decorateResult passes a negative value that rounds to zero as "-0" so its
402+
// sign survives. It must still get the locale, padding and separator that
403+
// any other zero gets.
404+
const negativeZero = result === "-0";
405+
401406
// When padding alongside a locale, let the locale formatter emit the fixed
402407
// number of fraction digits. The manual string padding below cannot tell a
403408
// locale-inserted grouping separator from the decimal separator, so it
@@ -406,11 +411,12 @@ function applyNumberFormatting(
406411
pad && round > 0 ? { minimumFractionDigits: round, maximumFractionDigits: round } : undefined;
407412

408413
// Strings from toPrecision ignore toLocaleString; preserve zero strings
409-
// so their precision (e.g. "0.00") is retained.
414+
// so their precision (e.g. "0.00") is retained. "-0" becomes the number -0,
415+
// which the locale formatter prints with its own minus sign.
410416
if (
411417
(locale === true || locale.length > 0) &&
412418
typeof result === "string" &&
413-
Number(result) !== 0
419+
(Number(result) !== 0 || negativeZero)
414420
) {
415421
result = parseFloat(result);
416422
}
@@ -423,7 +429,9 @@ function applyNumberFormatting(
423429
} else {
424430
// Round before separator replacement to ensure excess decimal places
425431
// are truncated when pad is also set (fixes padding + separator bug).
426-
if (separator.length > 0 && pad && round > 0) {
432+
// Skipped for "-0": the arithmetic would turn it into -0, whose string
433+
// form "0" drops the sign.
434+
if (separator.length > 0 && pad && round > 0 && !negativeZero) {
427435
const p = Math.pow(10, round);
428436
result = roundingFunc(result * p) / p;
429437
}

‎dist/filesize.min.js‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/filesize.min.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/filesize.umd.js‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
55
* @license BSD-3-Clause
6-
* @version 11.0.34
6+
* @version 11.0.35
77
*/
88
(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
99
const INVALID_NUMBER = "Invalid number";
@@ -398,6 +398,11 @@ function applyNumberFormatting(
398398
) {
399399
let result = value;
400400

401+
// decorateResult passes a negative value that rounds to zero as "-0" so its
402+
// sign survives. It must still get the locale, padding and separator that
403+
// any other zero gets.
404+
const negativeZero = result === "-0";
405+
401406
// When padding alongside a locale, let the locale formatter emit the fixed
402407
// number of fraction digits. The manual string padding below cannot tell a
403408
// locale-inserted grouping separator from the decimal separator, so it
@@ -406,11 +411,12 @@ function applyNumberFormatting(
406411
pad && round > 0 ? { minimumFractionDigits: round, maximumFractionDigits: round } : undefined;
407412

408413
// Strings from toPrecision ignore toLocaleString; preserve zero strings
409-
// so their precision (e.g. "0.00") is retained.
414+
// so their precision (e.g. "0.00") is retained. "-0" becomes the number -0,
415+
// which the locale formatter prints with its own minus sign.
410416
if (
411417
(locale === true || locale.length > 0) &&
412418
typeof result === "string" &&
413-
Number(result) !== 0
419+
(Number(result) !== 0 || negativeZero)
414420
) {
415421
result = parseFloat(result);
416422
}
@@ -423,7 +429,9 @@ function applyNumberFormatting(
423429
} else {
424430
// Round before separator replacement to ensure excess decimal places
425431
// are truncated when pad is also set (fixes padding + separator bug).
426-
if (separator.length > 0 && pad && round > 0) {
432+
// Skipped for "-0": the arithmetic would turn it into -0, whose string
433+
// form "0" drops the sign.
434+
if (separator.length > 0 && pad && round > 0 && !negativeZero) {
427435
const p = Math.pow(10, round);
428436
result = roundingFunc(result * p) / p;
429437
}

0 commit comments

Comments
 (0)