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
37 changes: 35 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,46 @@ All notable changes to this project will be documented in this file. Dates are d

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

#### [11.0.17](https://github.com/avoidwork/filesize.js/compare/11.0.16...11.0.17)

#### [11.0.18](https://github.com/avoidwork/filesize.js/compare/11.0.16...11.0.18)

@augmentcode augmentcode Bot Jun 26, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHANGELOG.md:7 — The compare link for 11.0.18 points to 11.0.16...11.0.18; is it intentional to skip 11.0.17 here? If 11.0.17 was released/tagged, this link may be misleading for readers.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.


- fix: stop dropping digits when pad is combined with a locale [`#292`](https://github.com/avoidwork/filesize.js/pull/292)
- Bump oxlint from 1.70.0 to 1.71.0 [`#294`](https://github.com/avoidwork/filesize.js/pull/294)
- Bump oxfmt from 0.55.0 to 0.56.0 [`#293`](https://github.com/avoidwork/filesize.js/pull/293)
- Bump rollup from 4.62.0 to 4.62.2 [`#291`](https://github.com/avoidwork/filesize.js/pull/291)
- Bump actions/checkout from 6 to 7 [`#290`](https://github.com/avoidwork/filesize.js/pull/290)
- Bump oxfmt from 0.54.0 to 0.55.0 [`#289`](https://github.com/avoidwork/filesize.js/pull/289)
- Bump oxlint from 1.69.0 to 1.70.0 [`#288`](https://github.com/avoidwork/filesize.js/pull/288)
- Bump rollup from 4.61.1 to 4.62.0 [`#287`](https://github.com/avoidwork/filesize.js/pull/287)
- Bump oxfmt from 0.53.0 to 0.54.0 [`#286`](https://github.com/avoidwork/filesize.js/pull/286)
- Bump oxlint from 1.68.0 to 1.69.0 [`#285`](https://github.com/avoidwork/filesize.js/pull/285)
- Bump rollup from 4.61.0 to 4.61.1 [`#284`](https://github.com/avoidwork/filesize.js/pull/284)
- Bump oxlint from 1.67.0 to 1.68.0 [`#283`](https://github.com/avoidwork/filesize.js/pull/283)
- Bump oxfmt from 0.52.0 to 0.53.0 [`#282`](https://github.com/avoidwork/filesize.js/pull/282)
- Bump auto-changelog from 2.5.1 to 2.6.0 [`#281`](https://github.com/avoidwork/filesize.js/pull/281)
- Bump rollup from 4.60.4 to 4.61.0 [`#280`](https://github.com/avoidwork/filesize.js/pull/280)
- Bump oxlint from 1.66.0 to 1.67.0 [`#279`](https://github.com/avoidwork/filesize.js/pull/279)
- Bump oxfmt from 0.51.0 to 0.52.0 [`#278`](https://github.com/avoidwork/filesize.js/pull/278)
- Bump oxlint from 1.65.0 to 1.66.0 [`#277`](https://github.com/avoidwork/filesize.js/pull/277)
- Bump oxfmt from 0.50.0 to 0.51.0 [`#276`](https://github.com/avoidwork/filesize.js/pull/276)
- Bump oxlint from 1.64.0 to 1.65.0 [`#275`](https://github.com/avoidwork/filesize.js/pull/275)
- Bump oxfmt from 0.49.0 to 0.50.0 [`#274`](https://github.com/avoidwork/filesize.js/pull/274)
- Bump rollup from 4.60.3 to 4.60.4 [`#273`](https://github.com/avoidwork/filesize.js/pull/273)
- docs: add PR template convention to AGENTS.md [`#272`](https://github.com/avoidwork/filesize.js/pull/272)
- Bump oxfmt from 0.48.0 to 0.49.0 [`#271`](https://github.com/avoidwork/filesize.js/pull/271)
- Bump oxlint from 1.63.0 to 1.64.0 [`#270`](https://github.com/avoidwork/filesize.js/pull/270)
- docs: restructure AGENTS.md to match retrieved file layout [`#269`](https://github.com/avoidwork/filesize.js/pull/269)
- Bump auto-changelog from 2.5.0 to 2.5.1 [`#268`](https://github.com/avoidwork/filesize.js/pull/268)
- Bump oxlint from 1.62.0 to 1.63.0 [`#267`](https://github.com/avoidwork/filesize.js/pull/267)
- Bump oxfmt from 0.47.0 to 0.48.0 [`#266`](https://github.com/avoidwork/filesize.js/pull/266)
- Bump rollup from 4.60.2 to 4.60.3 [`#265`](https://github.com/avoidwork/filesize.js/pull/265)
- Bump oxlint from 1.61.0 to 1.62.0 [`#264`](https://github.com/avoidwork/filesize.js/pull/264)
- Bump oxfmt from 0.46.0 to 0.47.0 [`#263`](https://github.com/avoidwork/filesize.js/pull/263)
- docs: update browser CDN URL to v11.0.16 [`#262`](https://github.com/avoidwork/filesize.js/pull/262)
- Bump oxfmt from 0.45.0 to 0.46.0 [`#260`](https://github.com/avoidwork/filesize.js/pull/260)
- Bump oxlint from 1.60.0 to 1.61.0 [`#259`](https://github.com/avoidwork/filesize.js/pull/259)
- Bump rollup from 4.60.1 to 4.60.2 [`#258`](https://github.com/avoidwork/filesize.js/pull/258)
- Version bump [`43320d8`](https://github.com/avoidwork/filesize.js/commit/43320d8cee21f39c9db01f0bdccca027e3353fe0)
- Updating CHANGELOG.md [`8f97c2a`](https://github.com/avoidwork/filesize.js/commit/8f97c2abe82813a7662a65e59be378766acb40c2)
- docs: remove Browser Usage section from README [`99136ff`](https://github.com/avoidwork/filesize.js/commit/99136ffb47dbc4236470e78dadcea9d139ebf54f)

#### [11.0.16](https://github.com/avoidwork/filesize.js/compare/11.0.15...11.0.16)
Expand Down
25 changes: 15 additions & 10 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.17
* @version 11.0.18
*/
'use strict';

Expand Down Expand Up @@ -290,26 +290,31 @@ function applyPrecisionHandling(
function applyNumberFormatting(value, locale, localeOptions, separator, pad, round) {
let result = value;

// When padding alongside a locale, let the locale formatter emit the fixed
// number of fraction digits. The manual string padding below cannot tell a
// locale-inserted grouping separator from the decimal separator, so it
// dropped digits (e.g. "1,234,500" became "1,234").
const localePad =
pad && round > 0 ? { minimumFractionDigits: round, maximumFractionDigits: round } : undefined;

// Apply locale formatting
if (locale === true) {
result = result.toLocaleString();
result = result.toLocaleString(undefined, localePad);
} else if (locale.length > 0) {
result = result.toLocaleString(locale, localeOptions);
result = result.toLocaleString(locale, { ...localeOptions, ...localePad });
} else if (separator.length > 0) {
result = result.toString().replace(PERIOD, separator);
}

// Apply padding
if (pad && round > 0) {
// Apply padding for the non-locale paths, where the string has a single
// decimal separator and no grouping is inserted.
if (pad && round > 0 && locale !== true && locale.length === 0) {
const resultStr = result.toString();
const x = separator || (resultStr.slice(1).match(/[.,]/g) || []).pop() || PERIOD;
const x = separator || PERIOD;
const tmp = resultStr.split(x);
const s = tmp[1] || EMPTY;

const l = s.length;
const n = round - l;

result = `${tmp[0]}${x}${s.padEnd(l + n, ZERO)}`;
result = `${tmp[0]}${x}${s.padEnd(round, ZERO)}`;
}

return result;
Expand Down
25 changes: 15 additions & 10 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.17
* @version 11.0.18
*/
// Error Messages
const INVALID_NUMBER = "Invalid number";
Expand Down Expand Up @@ -286,26 +286,31 @@ function applyPrecisionHandling(
function applyNumberFormatting(value, locale, localeOptions, separator, pad, round) {
let result = value;

// When padding alongside a locale, let the locale formatter emit the fixed
// number of fraction digits. The manual string padding below cannot tell a
// locale-inserted grouping separator from the decimal separator, so it
// dropped digits (e.g. "1,234,500" became "1,234").
const localePad =

@augmentcode augmentcode Bot Jun 26, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dist/filesize.js:293 — localePad sets minimumFractionDigits/maximumFractionDigits directly from round; Intl.NumberFormat typically enforces an upper bound (commonly 20), so pad: true + locale with a large round may throw a RangeError at runtime rather than formatting/padding.

Severity: medium

Other Locations
  • dist/filesize.cjs:297
  • dist/filesize.umd.js:293

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

pad && round > 0 ? { minimumFractionDigits: round, maximumFractionDigits: round } : undefined;

// Apply locale formatting
if (locale === true) {
result = result.toLocaleString();
result = result.toLocaleString(undefined, localePad);
} else if (locale.length > 0) {
result = result.toLocaleString(locale, localeOptions);
result = result.toLocaleString(locale, { ...localeOptions, ...localePad });
} else if (separator.length > 0) {
result = result.toString().replace(PERIOD, separator);
}

// Apply padding
if (pad && round > 0) {
// Apply padding for the non-locale paths, where the string has a single
// decimal separator and no grouping is inserted.
if (pad && round > 0 && locale !== true && locale.length === 0) {
const resultStr = result.toString();
const x = separator || (resultStr.slice(1).match(/[.,]/g) || []).pop() || PERIOD;
const x = separator || PERIOD;
const tmp = resultStr.split(x);
const s = tmp[1] || EMPTY;

const l = s.length;
const n = round - l;

result = `${tmp[0]}${x}${s.padEnd(l + n, ZERO)}`;
result = `${tmp[0]}${x}${s.padEnd(round, ZERO)}`;
}

return result;
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.

25 changes: 15 additions & 10 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.17
* @version 11.0.18
*/
(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 @@ -286,26 +286,31 @@ function applyPrecisionHandling(
function applyNumberFormatting(value, locale, localeOptions, separator, pad, round) {
let result = value;

// When padding alongside a locale, let the locale formatter emit the fixed
// number of fraction digits. The manual string padding below cannot tell a
// locale-inserted grouping separator from the decimal separator, so it
// dropped digits (e.g. "1,234,500" became "1,234").
const localePad =
pad && round > 0 ? { minimumFractionDigits: round, maximumFractionDigits: round } : undefined;

// Apply locale formatting
if (locale === true) {
result = result.toLocaleString();
result = result.toLocaleString(undefined, localePad);
} else if (locale.length > 0) {
result = result.toLocaleString(locale, localeOptions);
result = result.toLocaleString(locale, { ...localeOptions, ...localePad });
} else if (separator.length > 0) {
result = result.toString().replace(PERIOD, separator);
}

// Apply padding
if (pad && round > 0) {
// Apply padding for the non-locale paths, where the string has a single
// decimal separator and no grouping is inserted.
if (pad && round > 0 && locale !== true && locale.length === 0) {
const resultStr = result.toString();
const x = separator || (resultStr.slice(1).match(/[.,]/g) || []).pop() || PERIOD;
const x = separator || PERIOD;
const tmp = resultStr.split(x);
const s = tmp[1] || EMPTY;

const l = s.length;
const n = round - l;

result = `${tmp[0]}${x}${s.padEnd(l + n, ZERO)}`;
result = `${tmp[0]}${x}${s.padEnd(round, ZERO)}`;
}

return result;
Expand Down
Loading
Loading