From 2a5a4678eb05f6daa4232aaa0d698d9ef1c9c05f Mon Sep 17 00:00:00 2001 From: Jason Mulligan Date: Mon, 14 Sep 2026 21:21:39 -0400 Subject: [PATCH] chore: release v11.0.24 --- CHANGELOG.md | 12 ++++++++++++ dist/filesize.cjs | 2 +- dist/filesize.js | 2 +- dist/filesize.min.js | 2 +- dist/filesize.umd.js | 2 +- dist/filesize.umd.min.js | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 8 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39222cd..072eaed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,20 @@ 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.24](https://github.com/avoidwork/filesize.js/compare/11.0.23...11.0.24) + +- fix: harden input validation and edge-case handling in filesize() [`#344`](https://github.com/avoidwork/filesize.js/pull/344) +- chore(deps-dev): bump oxlint from 1.81.0 to 1.82.0 [`#342`](https://github.com/avoidwork/filesize.js/pull/342) +- chore(deps-dev): bump oxfmt from 0.66.0 to 0.67.0 [`#341`](https://github.com/avoidwork/filesize.js/pull/341) +- chore(deps-dev): bump auto-changelog from 2.6.0 to 2.6.1 [`#340`](https://github.com/avoidwork/filesize.js/pull/340) +- chore(deps-dev): bump oxlint from 1.80.0 to 1.81.0 [`#339`](https://github.com/avoidwork/filesize.js/pull/339) +- chore(deps-dev): bump oxfmt from 0.65.0 to 0.66.0 [`#338`](https://github.com/avoidwork/filesize.js/pull/338) + #### [11.0.23](https://github.com/avoidwork/filesize.js/compare/11.0.22...11.0.23) +> 3 September 2026 + +- chore: release v11.0.23 [`#336`](https://github.com/avoidwork/filesize.js/pull/336) - fix: keep precision trailing zeros for negative values [`#331`](https://github.com/avoidwork/filesize.js/pull/331) - chore(deps-dev): bump rollup from 4.63.0 to 4.63.1 [`#335`](https://github.com/avoidwork/filesize.js/pull/335) - chore(deps-dev): bump rollup from 4.62.5 to 4.63.0 [`#334`](https://github.com/avoidwork/filesize.js/pull/334) diff --git a/dist/filesize.cjs b/dist/filesize.cjs index 3de2315..8359dc0 100644 --- a/dist/filesize.cjs +++ b/dist/filesize.cjs @@ -3,7 +3,7 @@ * * @copyright 2026 Jason Mulligan * @license BSD-3-Clause - * @version 11.0.23 + * @version 11.0.24 */ 'use strict'; diff --git a/dist/filesize.js b/dist/filesize.js index ac3a848..fbf9883 100644 --- a/dist/filesize.js +++ b/dist/filesize.js @@ -3,7 +3,7 @@ * * @copyright 2026 Jason Mulligan * @license BSD-3-Clause - * @version 11.0.23 + * @version 11.0.24 */ // Error Messages const INVALID_NUMBER = "Invalid number"; diff --git a/dist/filesize.min.js b/dist/filesize.min.js index fae7ed8..7ced935 100644 --- a/dist/filesize.min.js +++ b/dist/filesize.min.js @@ -1,5 +1,5 @@ /*! 2026 Jason Mulligan - @version 11.0.23 + @version 11.0.24 */ const t="Invalid number",e="Invalid precision",i="iec",n="jedec",r="si",o="byte",a="array",s="object",l="string",u="exponent",c="round",f={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}},b=[1,1024,1048576,1073741824,1099511627776,0x4000000000000,0x1000000000000000,11805916207174113e5,12089258196146292e8],p=[1,1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24],d=Math.log(1024),m=Math.log(1e3),y={[r]:{isDecimal:!0,ceil:1e3,actualStandard:n},[i]:{isDecimal:!1,ceil:1024,actualStandard:i},[n]:{isDecimal:!1,ceil:1024,actualStandard:n}};function h(t,e,i,n,r,o=!0){let a;a=i?p[e]:b[e];let s=t/a;return n&&(s*=8,o&&s>=r&&e<8&&(s/=r,e++)),{result:s,e:e}}function M(r,{bits:b=!1,pad:p=!1,base:M=-1,round:B=2,locale:g="",localeOptions:N={},separator:w="",spacer:x=" ",symbols:S={},standard:v="",output:E=l,fullform:T=!1,fullforms:D=[],exponent:O=-1,roundingMethod:$=c,precision:F=0}={}){let G,j=O,k=[],I=0,J="";if(G=Number(r),isNaN(G))throw new TypeError(t);if(!isFinite(G))throw new TypeError(t);const{isDecimal:K,ceil:P,actualStandard:Y}=function(t,e){return y[t]?y[t]:2===e?{isDecimal:!1,ceil:1024,actualStandard:i}:{isDecimal:!0,ceil:1e3,actualStandard:n}}(v,M),Z=!0===T,z=G<0,C=Math[$];if("function"!=typeof C)throw new TypeError("Invalid rounding method");if(z&&(G=-G),0===G)return function(t,e,i,n,r,l,c,b,p,d,m){let y;return y=t>0?(0).toPrecision(t):p&&d>0?(0).toFixed(d):0,c===u?0:(m||(m=i?f.symbol[e].bits[0]:f.symbol[e].bytes[0]),n[m]&&(m=n[m]),r&&(l[0]?m=l[0]:(m=f.fullform[e][0],m+=i?"bit":o)),c===a?[y,m]:c===s?{value:y,symbol:m,exponent:0,unit:m}:y+b+m)}(F,Y,b,S,Z,D,E,x,p,B);const{e:U,precision:q}=function(t,e,i,n,r){return"string"==typeof e&&(e=Number(e)),-1===e||isNaN(e)?(e=n?Math.floor(Math.log(t)/m):Math.floor(Math.log(t)/d))<0&&(e=0):e=e<0?0:Math.floor(e),e>8?(r>0&&(r+=8-e),{e:8,precision:r}):{e:e,precision:r}}(G,j,0,K,F);j=U;const A=-1===O||isNaN(O),{result:H,e:L}=h(G,j,K,b,P,A);I=H,j=L;const Q=function(t,e,i,n,r,o){let a,s;return a=i>0&&n>0?Math.pow(10,n):1,s=1===a?r(t):r(t*a)/a,s===e&&i<8&&o&&(s=1,i++),{value:s,e:i}}(I,P,j,B,C,A);if(k[0]=Q.value,j=Q.e,q>0){const t=function(t,i,n,r,o,a,s,l,u,c){if("string"==typeof t&&(t=parseFloat(t)),"number"!=typeof i||isNaN(i))throw new TypeError(e);if((i=Math.floor(i))<1||i>100)throw new TypeError(e);let f=t.toPrecision(i);const b=-1===c||isNaN(c);if(f.includes("e")&&n<8&&b){n++;const{result:t}=h(r,n,o,a,s);let e,c;e=u>0?Math.pow(10,u):1,c=1===e?l(t):l(t*e)/e,f=c.toPrecision(i)}return{value:f,e:n}}(k[0],q,j,G,K,b,P,C,B,O);k[0]=t.value,j=t.e}return E===u?j:(J=function(t,e,i,n){const r=f.symbol[t][e?"bits":"bytes"];let o;return o=n&&1===i?e?"kbit":"kB":r[i],o}(Y,b,j,K),k[1]=J,function(t,e,i,n,r,a,s,l,u,c,b,p,d,m){let y;if(e&&("string"==typeof t[0]?t[0]=`-${t[0]}`:0===t[0]?t[0]="-0":t[0]=-t[0]),i[t[1]]&&(t[1]=i[t[1]]),y="string"==typeof t[0]?parseFloat(t[0]):t[0],t[0]=function(t,e,i,n,r,o,a){let s=t;const l=r&&o>0?{minimumFractionDigits:o,maximumFractionDigits:o}:void 0;if(!0===e)s=s.toLocaleString(void 0,l);else if(e.length>0)s=s.toLocaleString(e,{...i,...l});else if(n.length>0){if(r&&o>0){const t=Math.pow(10,o);s=a(s*t)/t}s=s.toString().replace(".",n)}if("number"==typeof s&&isFinite(s)&&s.toString().includes("e")&&(s=s.toLocaleString("en-US",{useGrouping:!1})),r&&o>0&&!0!==e&&0===e.length){const t=n||".",e=s.toString().split(t),i=e[1]||"";s=`${e[0]}${t}${i.padEnd(o,"0")}`}return s}(t[0],n,r,a,s,l,m),u){let e,i;e=d?"bit":o,i=1===Math.abs(y)?"":"s",c[p]?t[1]=c[p]:t[1]=f.fullform[b][p]+e+i}}(k,z,S,g,N,w,p,B,Z,D,Y,j,b,C),function(t,e,i,n,r){if(n!==a&&n!==s&&n!==l&&n!==u)throw new TypeError(`Invalid output: ${n}`);if(n===a)return t;if(n===s)return{value:t[0],symbol:t[1],exponent:e,unit:i};let o;return o=" "===r?`${t[0]} ${t[1]}`:t.join(r),o}(k,j,J,E,x))}function B({bits:t=!1,pad:e=!1,base:i=-1,round:n=2,locale:r="",separator:o="",spacer:a=" ",standard:s="",output:u=l,fullform:f=!1,exponent:b=-1,roundingMethod:p=c,precision:d=0,localeOptions:m={},symbols:y={},fullforms:h=[]}={}){function B(t){try{return"function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t))}catch{return JSON.parse(JSON.stringify(t))}}const g={localeOptions:B(m),symbols:B(y),fullforms:B(h)};return l=>M(l,{bits:t,pad:e,base:i,round:n,locale:r,localeOptions:g.localeOptions,separator:o,spacer:a,symbols:g.symbols,standard:s,output:u,fullform:f,fullforms:g.fullforms,exponent:b,roundingMethod:p,precision:d})}export{M as filesize,B as partial};//# sourceMappingURL=filesize.min.js.map diff --git a/dist/filesize.umd.js b/dist/filesize.umd.js index 8f76f85..70698b2 100644 --- a/dist/filesize.umd.js +++ b/dist/filesize.umd.js @@ -3,7 +3,7 @@ * * @copyright 2026 Jason Mulligan * @license BSD-3-Clause - * @version 11.0.23 + * @version 11.0.24 */ (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"; diff --git a/dist/filesize.umd.min.js b/dist/filesize.umd.min.js index c04116a..4906cd4 100644 --- a/dist/filesize.umd.min.js +++ b/dist/filesize.umd.min.js @@ -1,5 +1,5 @@ /*! 2026 Jason Mulligan - @version 11.0.23 + @version 11.0.24 */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).filesize={})}(this,function(t){"use strict";const e="Invalid number",i="Invalid precision",n="iec",o="jedec",r="si",a="byte",s="array",l="object",u="string",c="exponent",f="round",b={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}},p=[1,1024,1048576,1073741824,1099511627776,0x4000000000000,0x1000000000000000,11805916207174113e5,12089258196146292e8],d=[1,1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24],m=Math.log(1024),y=Math.log(1e3),h={[r]:{isDecimal:!0,ceil:1e3,actualStandard:o},[n]:{isDecimal:!1,ceil:1024,actualStandard:n},[o]:{isDecimal:!1,ceil:1024,actualStandard:o}};function M(t,e,i,n,o,r=!0){let a;a=i?d[e]:p[e];let s=t/a;return n&&(s*=8,r&&s>=o&&e<8&&(s/=o,e++)),{result:s,e:e}}function B(t,{bits:r=!1,pad:p=!1,base:d=-1,round:B=2,locale:g="",localeOptions:N={},separator:x="",spacer:w=" ",symbols:T={},standard:S="",output:v=u,fullform:E=!1,fullforms:D=[],exponent:O=-1,roundingMethod:$=f,precision:F=0}={}){let j,G=O,k=[],I=0,J="";if(j=Number(t),isNaN(j))throw new TypeError(e);if(!isFinite(j))throw new TypeError(e);const{isDecimal:K,ceil:P,actualStandard:Y}=function(t,e){return h[t]?h[t]:2===e?{isDecimal:!1,ceil:1024,actualStandard:n}:{isDecimal:!0,ceil:1e3,actualStandard:o}}(S,d),Z=!0===E,z=j<0,C=Math[$];if("function"!=typeof C)throw new TypeError("Invalid rounding method");if(z&&(j=-j),0===j)return function(t,e,i,n,o,r,u,f,p,d,m){let y;return y=t>0?(0).toPrecision(t):p&&d>0?(0).toFixed(d):0,u===c?0:(m||(m=i?b.symbol[e].bits[0]:b.symbol[e].bytes[0]),n[m]&&(m=n[m]),o&&(r[0]?m=r[0]:(m=b.fullform[e][0],m+=i?"bit":a)),u===s?[y,m]:u===l?{value:y,symbol:m,exponent:0,unit:m}:y+f+m)}(F,Y,r,T,Z,D,v,w,p,B);const{e:U,precision:q}=function(t,e,i,n,o){return"string"==typeof e&&(e=Number(e)),-1===e||isNaN(e)?(e=n?Math.floor(Math.log(t)/y):Math.floor(Math.log(t)/m))<0&&(e=0):e=e<0?0:Math.floor(e),e>8?(o>0&&(o+=8-e),{e:8,precision:o}):{e:e,precision:o}}(j,G,0,K,F);G=U;const A=-1===O||isNaN(O),{result:H,e:L}=M(j,G,K,r,P,A);I=H,G=L;const Q=function(t,e,i,n,o,r){let a,s;return a=i>0&&n>0?Math.pow(10,n):1,s=1===a?o(t):o(t*a)/a,s===e&&i<8&&r&&(s=1,i++),{value:s,e:i}}(I,P,G,B,C,A);if(k[0]=Q.value,G=Q.e,q>0){const t=function(t,e,n,o,r,a,s,l,u,c){if("string"==typeof t&&(t=parseFloat(t)),"number"!=typeof e||isNaN(e))throw new TypeError(i);if((e=Math.floor(e))<1||e>100)throw new TypeError(i);let f=t.toPrecision(e);const b=-1===c||isNaN(c);if(f.includes("e")&&n<8&&b){n++;const{result:t}=M(o,n,r,a,s);let i,c;i=u>0?Math.pow(10,u):1,c=1===i?l(t):l(t*i)/i,f=c.toPrecision(e)}return{value:f,e:n}}(k[0],q,G,j,K,r,P,C,B,O);k[0]=t.value,G=t.e}return v===c?G:(J=function(t,e,i,n){const o=b.symbol[t][e?"bits":"bytes"];let r;return r=n&&1===i?e?"kbit":"kB":o[i],r}(Y,r,G,K),k[1]=J,function(t,e,i,n,o,r,s,l,u,c,f,p,d,m){let y;if(e&&("string"==typeof t[0]?t[0]=`-${t[0]}`:0===t[0]?t[0]="-0":t[0]=-t[0]),i[t[1]]&&(t[1]=i[t[1]]),y="string"==typeof t[0]?parseFloat(t[0]):t[0],t[0]=function(t,e,i,n,o,r,a){let s=t;const l=o&&r>0?{minimumFractionDigits:r,maximumFractionDigits:r}:void 0;if(!0===e)s=s.toLocaleString(void 0,l);else if(e.length>0)s=s.toLocaleString(e,{...i,...l});else if(n.length>0){if(o&&r>0){const t=Math.pow(10,r);s=a(s*t)/t}s=s.toString().replace(".",n)}if("number"==typeof s&&isFinite(s)&&s.toString().includes("e")&&(s=s.toLocaleString("en-US",{useGrouping:!1})),o&&r>0&&!0!==e&&0===e.length){const t=n||".",e=s.toString().split(t),i=e[1]||"";s=`${e[0]}${t}${i.padEnd(r,"0")}`}return s}(t[0],n,o,r,s,l,m),u){let e,i;e=d?"bit":a,i=1===Math.abs(y)?"":"s",c[p]?t[1]=c[p]:t[1]=b.fullform[f][p]+e+i}}(k,z,T,g,N,x,p,B,Z,D,Y,G,r,C),function(t,e,i,n,o){if(n!==s&&n!==l&&n!==u&&n!==c)throw new TypeError(`Invalid output: ${n}`);if(n===s)return t;if(n===l)return{value:t[0],symbol:t[1],exponent:e,unit:i};let r;return r=" "===o?`${t[0]} ${t[1]}`:t.join(o),r}(k,G,J,v,w))}t.filesize=B,t.partial=function({bits:t=!1,pad:e=!1,base:i=-1,round:n=2,locale:o="",separator:r="",spacer:a=" ",standard:s="",output:l=u,fullform:c=!1,exponent:b=-1,roundingMethod:p=f,precision:d=0,localeOptions:m={},symbols:y={},fullforms:h=[]}={}){function M(t){try{return"function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t))}catch{return JSON.parse(JSON.stringify(t))}}const g={localeOptions:M(m),symbols:M(y),fullforms:M(h)};return u=>B(u,{bits:t,pad:e,base:i,round:n,locale:o,localeOptions:g.localeOptions,separator:r,spacer:a,symbols:g.symbols,standard:s,output:l,fullform:c,fullforms:g.fullforms,exponent:b,roundingMethod:p,precision:d})}});//# sourceMappingURL=filesize.umd.min.js.map diff --git a/package-lock.json b/package-lock.json index f4a4103..cc98eb2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "filesize", - "version": "11.0.23", + "version": "11.0.24", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "filesize", - "version": "11.0.23", + "version": "11.0.24", "license": "BSD-3-Clause", "devDependencies": { "@rollup/plugin-terser": "^1.0.0", diff --git a/package.json b/package.json index 2ce4912..91304fa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "filesize", "description": "Lightweight, zero-dependency JavaScript utility to convert bytes to human-readable strings with localization support", - "version": "11.0.23", + "version": "11.0.24", "homepage": "https://filesizejs.com", "author": "Jason Mulligan ", "repository": {