diff --git a/CHANGELOG.md b/CHANGELOG.md index fa4fc8b..71dab63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,16 @@ 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.19](https://github.com/avoidwork/filesize.js/compare/11.0.18...11.0.19) + +- fix: resolve audit findings — padding truncation, isNaN clarity, structuredClone [`#300`](https://github.com/avoidwork/filesize.js/pull/300) +- docs: add issue templates, security policy, and update contributing guide [`#299`](https://github.com/avoidwork/filesize.js/pull/299) + #### [11.0.18](https://github.com/avoidwork/filesize.js/compare/11.0.16...11.0.18) +> 25 June 2026 + +- chore: release v11.0.18 [`#295`](https://github.com/avoidwork/filesize.js/pull/295) - 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) diff --git a/dist/filesize.cjs b/dist/filesize.cjs index 2fb3a30..cef1a38 100644 --- a/dist/filesize.cjs +++ b/dist/filesize.cjs @@ -3,7 +3,7 @@ * * @copyright 2026 Jason Mulligan * @license BSD-3-Clause - * @version 11.0.18 + * @version 11.0.19 */ 'use strict'; diff --git a/dist/filesize.js b/dist/filesize.js index 65c6de9..4f1871d 100644 --- a/dist/filesize.js +++ b/dist/filesize.js @@ -3,7 +3,7 @@ * * @copyright 2026 Jason Mulligan * @license BSD-3-Clause - * @version 11.0.18 + * @version 11.0.19 */ // Error Messages const INVALID_NUMBER = "Invalid number"; diff --git a/dist/filesize.min.js b/dist/filesize.min.js index ac3d40c..cbc7b7a 100644 --- a/dist/filesize.min.js +++ b/dist/filesize.min.js @@ -1,5 +1,5 @@ /*! 2026 Jason Mulligan - @version 11.0.18 + @version 11.0.19 */ const t="Invalid number",e="iec",i="jedec",n="si",o="byte",r="array",a="object",s="string",l="exponent",u="round",c={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],f=[1,1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24],d=Math.log(1024),p=Math.log(1e3),m={[n]:{isDecimal:!0,ceil:1e3,actualStandard:i},[e]:{isDecimal:!1,ceil:1024,actualStandard:e},[i]:{isDecimal:!1,ceil:1024,actualStandard:i}};function y(t,e,i,n,o,r=!0){let a;a=i?f[e]:b[e];let s=t/a;return n&&(s*=8,r&&s>=o&&e<8&&(s/=o,e++)),{result:s,e:e}}function B(n,{bits:b=!1,pad:f=!1,base:B=-1,round:h=2,locale:M="",localeOptions:g={},separator:N="",spacer:x=" ",symbols:S={},standard:v="",output:D=s,fullform:O=!1,fullforms:E=[],exponent:T=-1,roundingMethod:w=u,precision:F=0}={}){let $,j=T,k=[],G=0,J="";if("bigint"==typeof n)$=Number(n);else{if($=Number(n),isNaN($))throw new TypeError(t);if(!isFinite($))throw new TypeError(t)}const{isDecimal:K,ceil:P,actualStandard:Y}=function(t,n){return m[t]?m[t]:2===n?{isDecimal:!1,ceil:1024,actualStandard:e}:{isDecimal:!0,ceil:1e3,actualStandard:i}}(v,B),Z=!0===O,z=$<0,C=Math[w];if("function"!=typeof C)throw new TypeError("Invalid rounding method");if(z&&($=-$),0===$)return function(t,e,i,n,s,u,b,f,d){let p;return p=t>0?(0).toPrecision(t):0,b===l?0:(d||(d=i?c.symbol[e].bits[0]:c.symbol[e].bytes[0]),n[d]&&(d=n[d]),s&&(u[0]?d=u[0]:(d=c.fullform[e][0],d+=i?"bit":o)),b===r?[p,d]:b===a?{value:p,symbol:d,exponent:0,unit:d}:p+f+d)}(F,Y,b,S,Z,E,D,x);const{e:I,precision:q}=function(t,e,i,n,o){return(-1===e||isNaN(e))&&(e=n?Math.floor(Math.log(t)/p):Math.floor(Math.log(t)/d))<0&&(e=0),e>8?(o>0&&(o+=8-e),{e:8,precision:o}):{e:e,precision:o}}($,j,0,K,F);j=I;const A=-1===T||isNaN(T);if(D===l)return j;const{result:H,e:L}=y($,j,K,b,P,A);G=H,j=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}}(G,P,j,h,C,A);if(k[0]=Q.value,j=Q.e,q>0){const t=function(t,e,i,n,o,r,a,s,l,u){"string"==typeof t&&(t=parseFloat(t));let c=t.toPrecision(e);const b=-1===u||isNaN(u);if(c.includes("e")&&i<8&&b){i++;const{result:t}=y(n,i,o,r,a);let u,b;u=l>0?Math.pow(10,l):1,b=1===u?s(t):s(t*u)/u,c=b.toPrecision(e)}return{value:c,e:i}}(k[0],q,j,$,K,b,P,C,h,T);k[0]=t.value,j=t.e}return J=function(t,e,i,n){const o=c.symbol[t][e?"bits":"bytes"];let r;return r=n&&1===i?e?"kbit":"kB":o[i],r}(Y,b,j,K),k[1]=J,function(t,e,i,n,r,a,s,l,u,b,f,d,p,m){if(e&&(t[0]=-t[0]),i[t[1]]&&(t[1]=i[t[1]]),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(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,r,a,s,l,m),u){let e,i,n;e=p?"bit":o,i="string"==typeof t[0]?parseFloat(t[0]):t[0],n=1===i?"":"s",b[d]?t[1]=b[d]:t[1]=c.fullform[f][d]+e+n}}(k,z,S,M,g,N,f,h,Z,E,Y,j,b,C),function(t,e,i,n,o){if(n===r)return t;if(n===a)return{value:t[0],symbol:t[1],exponent:e,unit:i};let s;return s=" "===o?`${t[0]} ${t[1]}`:t.join(o),s}(k,j,J,D,x)}function h({bits:t=!1,pad:e=!1,base:i=-1,round:n=2,locale:o="",separator:r="",spacer:a=" ",standard:l="",output:c=s,fullform:b=!1,exponent:f=-1,roundingMethod:d=u,precision:p=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 s=>B(s,{bits:t,pad:e,base:i,round:n,locale:o,localeOptions:g.localeOptions,separator:r,spacer:a,symbols:g.symbols,standard:l,output:c,fullform:b,fullforms:g.fullforms,exponent:f,roundingMethod:d,precision:p})}export{B as filesize,h as partial};//# sourceMappingURL=filesize.min.js.map diff --git a/dist/filesize.umd.js b/dist/filesize.umd.js index 0bee445..9b3c061 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.18 + * @version 11.0.19 */ (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 e3fabf8..8178a61 100644 --- a/dist/filesize.umd.min.js +++ b/dist/filesize.umd.min.js @@ -1,5 +1,5 @@ /*! 2026 Jason Mulligan - @version 11.0.18 + @version 11.0.19 */ !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="iec",n="jedec",o="si",r="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],d=[1,1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24],p=Math.log(1024),m=Math.log(1e3),y={[o]:{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,o,r=!0){let a;a=i?d[e]:b[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:o=!1,pad:b=!1,base:d=-1,round:B=2,locale:M="",localeOptions:g={},separator:x="",spacer:N=" ",symbols:S={},standard:T="",output:v=l,fullform:D=!1,fullforms:O=[],exponent:E=-1,roundingMethod:w=c,precision:j=0}={}){let F,$=E,k=[],G=0,J="";if("bigint"==typeof t)F=Number(t);else{if(F=Number(t),isNaN(F))throw new TypeError(e);if(!isFinite(F))throw new TypeError(e)}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}}(T,d),Z=!0===D,z=F<0,C=Math[w];if("function"!=typeof C)throw new TypeError("Invalid rounding method");if(z&&(F=-F),0===F)return function(t,e,i,n,o,l,c,b,d){let p;return p=t>0?(0).toPrecision(t):0,c===u?0:(d||(d=i?f.symbol[e].bits[0]:f.symbol[e].bytes[0]),n[d]&&(d=n[d]),o&&(l[0]?d=l[0]:(d=f.fullform[e][0],d+=i?"bit":r)),c===a?[p,d]:c===s?{value:p,symbol:d,exponent:0,unit:d}:p+b+d)}(j,Y,o,S,Z,O,v,N);const{e:I,precision:q}=function(t,e,i,n,o){return(-1===e||isNaN(e))&&(e=n?Math.floor(Math.log(t)/m):Math.floor(Math.log(t)/p))<0&&(e=0),e>8?(o>0&&(o+=8-e),{e:8,precision:o}):{e:e,precision:o}}(F,$,0,K,j);$=I;const A=-1===E||isNaN(E);if(v===u)return $;const{result:H,e:L}=h(F,$,K,o,P,A);G=H,$=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}}(G,P,$,B,C,A);if(k[0]=Q.value,$=Q.e,q>0){const t=function(t,e,i,n,o,r,a,s,l,u){"string"==typeof t&&(t=parseFloat(t));let c=t.toPrecision(e);const f=-1===u||isNaN(u);if(c.includes("e")&&i<8&&f){i++;const{result:t}=h(n,i,o,r,a);let u,f;u=l>0?Math.pow(10,l):1,f=1===u?s(t):s(t*u)/u,c=f.toPrecision(e)}return{value:c,e:i}}(k[0],q,$,F,K,o,P,C,B,E);k[0]=t.value,$=t.e}return J=function(t,e,i,n){const o=f.symbol[t][e?"bits":"bytes"];let r;return r=n&&1===i?e?"kbit":"kB":o[i],r}(Y,o,$,K),k[1]=J,function(t,e,i,n,o,a,s,l,u,c,b,d,p,m){if(e&&(t[0]=-t[0]),i[t[1]]&&(t[1]=i[t[1]]),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(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,a,s,l,m),u){let e,i,n;e=p?"bit":r,i="string"==typeof t[0]?parseFloat(t[0]):t[0],n=1===i?"":"s",c[d]?t[1]=c[d]:t[1]=f.fullform[b][d]+e+n}}(k,z,S,M,g,x,b,B,Z,O,Y,$,o,C),function(t,e,i,n,o){if(n===a)return t;if(n===s)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,$,J,v,N)}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:u=l,fullform:f=!1,exponent:b=-1,roundingMethod:d=c,precision:p=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 l=>B(l,{bits:t,pad:e,base:i,round:n,locale:o,localeOptions:g.localeOptions,separator:r,spacer:a,symbols:g.symbols,standard:s,output:u,fullform:f,fullforms:g.fullforms,exponent:b,roundingMethod:d,precision:p})}});//# sourceMappingURL=filesize.umd.min.js.map diff --git a/package-lock.json b/package-lock.json index 34a542e..64f3ccf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "filesize", - "version": "11.0.18", + "version": "11.0.19", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "filesize", - "version": "11.0.18", + "version": "11.0.19", "license": "BSD-3-Clause", "devDependencies": { "@rollup/plugin-terser": "^1.0.0", diff --git a/package.json b/package.json index 9a3456d..4817032 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.18", + "version": "11.0.19", "homepage": "https://filesizejs.com", "author": "Jason Mulligan ", "repository": {