diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e3b580..fa4fc8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) + +- 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) diff --git a/dist/filesize.cjs b/dist/filesize.cjs index a7775e4..6ffc208 100644 --- a/dist/filesize.cjs +++ b/dist/filesize.cjs @@ -3,7 +3,7 @@ * * @copyright 2026 Jason Mulligan * @license BSD-3-Clause - * @version 11.0.17 + * @version 11.0.18 */ 'use strict'; @@ -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; diff --git a/dist/filesize.js b/dist/filesize.js index 9273c95..a14de12 100644 --- a/dist/filesize.js +++ b/dist/filesize.js @@ -3,7 +3,7 @@ * * @copyright 2026 Jason Mulligan * @license BSD-3-Clause - * @version 11.0.17 + * @version 11.0.18 */ // Error Messages const INVALID_NUMBER = "Invalid number"; @@ -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; diff --git a/dist/filesize.min.js b/dist/filesize.min.js index 85d495a..6d2e307 100644 --- a/dist/filesize.min.js +++ b/dist/filesize.min.js @@ -1,5 +1,5 @@ /*! 2026 Jason Mulligan - @version 11.0.17 + @version 11.0.18 */ -const t="Invalid number",e="iec",i="jedec",n="si",o="byte",r="array",a="object",l="string",s="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],p=Math.log(1024),d=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 l=t/a;return n&&(l*=8,r&&l>=o&&e<8&&(l/=o,e++)),{result:l,e:e}}function B(n,{bits:b=!1,pad:f=!1,base:B=-1,round:h=2,locale:M="",localeOptions:N={},separator:g="",spacer:S=" ",symbols:x={},standard:O="",output:E=l,fullform:T=!1,fullforms:v=[],exponent:w=-1,roundingMethod:D=u,precision:J=0}={}){let $,j=w,k=[],G=0,K="";if("bigint"==typeof n)$=Number(n);else{if($=Number(n),isNaN(n))throw new TypeError(t);if(!isFinite($))throw new TypeError(t)}const{isDecimal:P,ceil:Y,actualStandard:Z}=function(t,n){return m[t]?m[t]:2===n?{isDecimal:!1,ceil:1024,actualStandard:e}:{isDecimal:!0,ceil:1e3,actualStandard:i}}(O,B),F=!0===T,z=$<0,I=Math[D];if("function"!=typeof I)throw new TypeError("Invalid rounding method");if(z&&($=-$),0===$)return function(t,e,i,n,l,u,b,f,p){let d;return d=t>0?(0).toPrecision(t):0,b===s?0:(p||(p=i?c.symbol[e].bits[0]:c.symbol[e].bytes[0]),n[p]&&(p=n[p]),l&&(u[0]?p=u[0]:(p=c.fullform[e][0],p+=i?"bit":o)),b===r?[d,p]:b===a?{value:d,symbol:p,exponent:0,unit:p}:d+f+p)}(J,Z,b,x,F,v,E,S);const{e:q,precision:A}=function(t,e,i,n,o){return(-1===e||isNaN(e))&&(e=n?Math.floor(Math.log(t)/d):Math.floor(Math.log(t)/p))<0&&(e=0),e>8?(o>0&&(o+=8-e),{e:8,precision:o}):{e:e,precision:o}}($,j,0,P,J);j=q;const C=-1===w||isNaN(w);if(E===s)return j;const{result:H,e:L}=y($,j,P,b,Y,C);G=H,j=L;const Q=function(t,e,i,n,o,r){let a,l;return a=i>0&&n>0?Math.pow(10,n):1,l=1===a?o(t):o(t*a)/a,l===e&&i<8&&r&&(l=1,i++),{value:l,e:i}}(G,Y,j,h,I,C);if(k[0]=Q.value,j=Q.e,A>0){const t=function(t,e,i,n,o,r,a,l,s,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=s>0?Math.pow(10,s):1,b=1===u?l(t):l(t*u)/u,c=b.toPrecision(e)}return{value:c,e:i}}(k[0],A,j,$,P,b,Y,I,h,w);k[0]=t.value,j=t.e}return K=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}(Z,b,j,P),k[1]=K,function(t,e,i,n,r,a,l,s,u,b,f,p,d){if(e&&(t[0]=-t[0]),i[t[1]]&&(t[1]=i[t[1]]),t[0]=function(t,e,i,n,o,r){let a=t;if(!0===e?a=a.toLocaleString():e.length>0?a=a.toLocaleString(e,i):n.length>0&&(a=a.toString().replace(".",n)),o&&r>0){const t=a.toString(),e=n||(t.slice(1).match(/[.,]/g)||[]).pop()||".",i=t.split(e),o=i[1]||"",l=o.length,s=r-l;a=`${i[0]}${e}${o.padEnd(l+s,"0")}`}return a}(t[0],n,r,a,l,s),u){let e,i,n;e=d?"bit":o,i="string"==typeof t[0]?parseFloat(t[0]):t[0],n=1===i?"":"s",b[p]?t[1]=b[p]:t[1]=c.fullform[f][p]+e+n}}(k,z,x,M,N,g,f,h,F,v,Z,j,b),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 l;return l=" "===o?`${t[0]} ${t[1]}`:t.join(o),l}(k,j,K,E,S)}function h({bits:t=!1,pad:e=!1,base:i=-1,round:n=2,locale:o="",separator:r="",spacer:a=" ",standard:s="",output:c=l,fullform:b=!1,exponent:f=-1,roundingMethod:p=u,precision:d=0,localeOptions:m={},symbols:y={},fullforms:h=[]}={}){const M={localeOptions:JSON.parse(JSON.stringify(m)),symbols:JSON.parse(JSON.stringify(y)),fullforms:JSON.parse(JSON.stringify(h))};return l=>B(l,{bits:t,pad:e,base:i,round:n,locale:o,localeOptions:M.localeOptions,separator:r,spacer:a,symbols:M.symbols,standard:s,output:c,fullform:b,fullforms:M.fullforms,exponent:f,roundingMethod:p,precision:d})}export{B as filesize,h as partial};//# sourceMappingURL=filesize.min.js.map +const t="Invalid number",i="iec",e="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:e},[i]:{isDecimal:!1,ceil:1024,actualStandard:i},[e]:{isDecimal:!1,ceil:1024,actualStandard:e}};function y(t,i,e,n,o,r=!0){let a;a=e?f[i]:b[i];let s=t/a;return n&&(s*=8,r&&s>=o&&i<8&&(s/=o,i++)),{result:s,e:i}}function B(n,{bits:b=!1,pad:f=!1,base:B=-1,round:h=2,locale:M="",localeOptions:N={},separator:g="",spacer:x=" ",symbols:S={},standard:O="",output:v=s,fullform:D=!1,fullforms:E=[],exponent:T=-1,roundingMethod:w=u,precision:J=0}={}){let F,$=T,j=[],k=0,G="";if("bigint"==typeof n)F=Number(n);else{if(F=Number(n),isNaN(n))throw new TypeError(t);if(!isFinite(F))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:i}:{isDecimal:!0,ceil:1e3,actualStandard:e}}(O,B),Z=!0===D,z=F<0,I=Math[w];if("function"!=typeof I)throw new TypeError("Invalid rounding method");if(z&&(F=-F),0===F)return function(t,i,e,n,s,u,b,f,d){let p;return p=t>0?(0).toPrecision(t):0,b===l?0:(d||(d=e?c.symbol[i].bits[0]:c.symbol[i].bytes[0]),n[d]&&(d=n[d]),s&&(u[0]?d=u[0]:(d=c.fullform[i][0],d+=e?"bit":o)),b===r?[p,d]:b===a?{value:p,symbol:d,exponent:0,unit:d}:p+f+d)}(J,Y,b,S,Z,E,v,x);const{e:q,precision:A}=function(t,i,e,n,o){return(-1===i||isNaN(i))&&(i=n?Math.floor(Math.log(t)/p):Math.floor(Math.log(t)/d))<0&&(i=0),i>8?(o>0&&(o+=8-i),{e:8,precision:o}):{e:i,precision:o}}(F,$,0,K,J);$=q;const C=-1===T||isNaN(T);if(v===l)return $;const{result:H,e:L}=y(F,$,K,b,P,C);k=H,$=L;const Q=function(t,i,e,n,o,r){let a,s;return a=e>0&&n>0?Math.pow(10,n):1,s=1===a?o(t):o(t*a)/a,s===i&&e<8&&r&&(s=1,e++),{value:s,e:e}}(k,P,$,h,I,C);if(j[0]=Q.value,$=Q.e,A>0){const t=function(t,i,e,n,o,r,a,s,l,u){"string"==typeof t&&(t=parseFloat(t));let c=t.toPrecision(i);const b=-1===u||isNaN(u);if(c.includes("e")&&e<8&&b){e++;const{result:t}=y(n,e,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(i)}return{value:c,e:e}}(j[0],A,$,F,K,b,P,I,h,T);j[0]=t.value,$=t.e}return G=function(t,i,e,n){const o=c.symbol[t][i?"bits":"bytes"];let r;return r=n&&1===e?i?"kbit":"kB":o[e],r}(Y,b,$,K),j[1]=G,function(t,i,e,n,r,a,s,l,u,b,f,d,p){if(i&&(t[0]=-t[0]),e[t[1]]&&(t[1]=e[t[1]]),t[0]=function(t,i,e,n,o,r){let a=t;const s=o&&r>0?{minimumFractionDigits:r,maximumFractionDigits:r}:void 0;if(!0===i?a=a.toLocaleString(void 0,s):i.length>0?a=a.toLocaleString(i,{...e,...s}):n.length>0&&(a=a.toString().replace(".",n)),o&&r>0&&!0!==i&&0===i.length){const t=n||".",i=a.toString().split(t),e=i[1]||"";a=`${i[0]}${t}${e.padEnd(r,"0")}`}return a}(t[0],n,r,a,s,l),u){let i,e,n;i=p?"bit":o,e="string"==typeof t[0]?parseFloat(t[0]):t[0],n=1===e?"":"s",b[d]?t[1]=b[d]:t[1]=c.fullform[f][d]+i+n}}(j,z,S,M,N,g,f,h,Z,E,Y,$,b),function(t,i,e,n,o){if(n===r)return t;if(n===a)return{value:t[0],symbol:t[1],exponent:i,unit:e};let s;return s=" "===o?`${t[0]} ${t[1]}`:t.join(o),s}(j,$,G,v,x)}function h({bits:t=!1,pad:i=!1,base:e=-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=[]}={}){const M={localeOptions:JSON.parse(JSON.stringify(m)),symbols:JSON.parse(JSON.stringify(y)),fullforms:JSON.parse(JSON.stringify(h))};return s=>B(s,{bits:t,pad:i,base:e,round:n,locale:o,localeOptions:M.localeOptions,separator:r,spacer:a,symbols:M.symbols,standard:l,output:c,fullform:b,fullforms:M.fullforms,exponent:f,roundingMethod:d,precision:p})}export{B as filesize,h as partial};//# sourceMappingURL=filesize.min.js.map diff --git a/dist/filesize.min.js.map b/dist/filesize.min.js.map index 4e9eb7b..eff862d 100644 --- a/dist/filesize.min.js.map +++ b/dist/filesize.min.js.map @@ -1 +1 @@ -{"version":3,"file":"filesize.min.js","sources":["../src/constants.js","../src/helpers.js","../src/filesize.js"],"sourcesContent":["// Error Messages\nexport const INVALID_NUMBER = \"Invalid number\";\nexport const INVALID_ROUND = \"Invalid rounding method\";\n\n// Standard Types\nexport const IEC = \"iec\";\nexport const JEDEC = \"jedec\";\nexport const SI = \"si\";\n\n// Unit Types\nexport const BIT = \"bit\";\nexport const BITS = \"bits\";\nexport const BYTE = \"byte\";\nexport const BYTES = \"bytes\";\nexport const SI_KBIT = \"kbit\";\nexport const SI_KBYTE = \"kB\";\n\n// Output Format Types\nexport const ARRAY = \"array\";\nexport const FUNCTION = \"function\";\nexport const OBJECT = \"object\";\nexport const STRING = \"string\";\n\n// Processing Constants\nexport const EXPONENT = \"exponent\";\nexport const ROUND = \"round\";\n\n// Special Characters and Values\nexport const E = \"e\";\nexport const EMPTY = \"\";\nexport const PERIOD = \".\";\nexport const S = \"s\";\nexport const SPACE = \" \";\nexport const ZERO = \"0\";\n\n// Data Structures\nexport const STRINGS = {\n\tsymbol: {\n\t\tiec: {\n\t\t\tbits: [\"bit\", \"Kibit\", \"Mibit\", \"Gibit\", \"Tibit\", \"Pibit\", \"Eibit\", \"Zibit\", \"Yibit\"],\n\t\t\tbytes: [\"B\", \"KiB\", \"MiB\", \"GiB\", \"TiB\", \"PiB\", \"EiB\", \"ZiB\", \"YiB\"],\n\t\t},\n\t\tjedec: {\n\t\t\tbits: [\"bit\", \"Kbit\", \"Mbit\", \"Gbit\", \"Tbit\", \"Pbit\", \"Ebit\", \"Zbit\", \"Ybit\"],\n\t\t\tbytes: [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"],\n\t\t},\n\t},\n\tfullform: {\n\t\tiec: [\"\", \"kibi\", \"mebi\", \"gibi\", \"tebi\", \"pebi\", \"exbi\", \"zebi\", \"yobi\"],\n\t\tjedec: [\"\", \"kilo\", \"mega\", \"giga\", \"tera\", \"peta\", \"exa\", \"zetta\", \"yotta\"],\n\t},\n};\n\n// Pre-computed lookup tables for performance optimization\nexport const BINARY_POWERS = [\n\t1, // 2^0\n\t1024, // 2^10\n\t1048576, // 2^20\n\t1073741824, // 2^30\n\t1099511627776, // 2^40\n\t1125899906842624, // 2^50\n\t1152921504606846976, // 2^60\n\t1180591620717411303424, // 2^70\n\t1208925819614629174706176, // 2^80\n];\n\nexport const DECIMAL_POWERS = [\n\t1, // 10^0\n\t1000, // 10^3\n\t1000000, // 10^6\n\t1000000000, // 10^9\n\t1000000000000, // 10^12\n\t1000000000000000, // 10^15\n\t1000000000000000000, // 10^18\n\t1000000000000000000000, // 10^21\n\t1000000000000000000000000, // 10^24\n];\n\n// Pre-computed log values for faster exponent calculation\nexport const LOG_2_1024 = Math.log(1024);\nexport const LOG_10_1000 = Math.log(1000);\n","import {\n\tARRAY,\n\tBINARY_POWERS,\n\tBIT,\n\tBITS,\n\tBYTE,\n\tBYTES,\n\tDECIMAL_POWERS,\n\tE,\n\tEMPTY,\n\tEXPONENT,\n\tIEC,\n\tJEDEC,\n\tLOG_10_1000,\n\tLOG_2_1024,\n\tOBJECT,\n\tPERIOD,\n\tS,\n\tSI,\n\tSI_KBIT,\n\tSI_KBYTE,\n\tSPACE,\n\tSTRINGS,\n\tZERO,\n} from \"./constants.js\";\n\n// Cached configuration lookup for better performance\nconst STANDARD_CONFIGS = {\n\t[SI]: { isDecimal: true, ceil: 1000, actualStandard: JEDEC },\n\t[IEC]: { isDecimal: false, ceil: 1024, actualStandard: IEC },\n\t[JEDEC]: { isDecimal: false, ceil: 1024, actualStandard: JEDEC },\n};\n\n/**\n * Optimized base configuration lookup\n * @param {string} standard - Standard type\n * @param {number} base - Base number\n * @returns {Object} Configuration object\n */\nexport function getBaseConfiguration(standard, base) {\n\t// Use cached lookup table for better performance\n\tif (STANDARD_CONFIGS[standard]) {\n\t\treturn STANDARD_CONFIGS[standard];\n\t}\n\n\t// Base override\n\tif (base === 2) {\n\t\treturn { isDecimal: false, ceil: 1024, actualStandard: IEC };\n\t}\n\n\t// Default\n\treturn { isDecimal: true, ceil: 1000, actualStandard: JEDEC };\n}\n\n/**\n * Optimized zero value handling\n * @param {number} precision - Precision value\n * @param {string} actualStandard - Standard to use\n * @param {boolean} bits - Whether to use bits\n * @param {Object} symbols - Custom symbols\n * @param {boolean} full - Whether to use full form\n * @param {Array} fullforms - Custom full forms\n * @param {string} output - Output format\n * @param {string} spacer - Spacer character\n * @param {string} [symbol] - Symbol to use (defaults based on bits/standard)\n * @returns {string|Array|Object|number} Formatted result\n */\nexport function handleZeroValue(\n\tprecision,\n\tactualStandard,\n\tbits,\n\tsymbols,\n\tfull,\n\tfullforms,\n\toutput,\n\tspacer,\n\tsymbol,\n) {\n\tlet value;\n\tif (precision > 0) {\n\t\tvalue = (0).toPrecision(precision);\n\t} else {\n\t\tvalue = 0;\n\t}\n\n\tif (output === EXPONENT) {\n\t\treturn 0;\n\t}\n\n\t// Set default symbol if not provided\n\tif (!symbol) {\n\t\tsymbol = bits\n\t\t\t? STRINGS.symbol[actualStandard].bits[0]\n\t\t\t: STRINGS.symbol[actualStandard].bytes[0];\n\t}\n\n\t// Apply symbol customization\n\tif (symbols[symbol]) {\n\t\tsymbol = symbols[symbol];\n\t}\n\n\t// Apply full form\n\tif (full) {\n\t\tif (fullforms[0]) {\n\t\t\tsymbol = fullforms[0];\n\t\t} else {\n\t\t\tsymbol = STRINGS.fullform[actualStandard][0];\n\t\t\tif (bits) {\n\t\t\t\tsymbol += BIT;\n\t\t\t} else {\n\t\t\t\tsymbol += BYTE;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return in requested format\n\tif (output === ARRAY) {\n\t\treturn [value, symbol];\n\t}\n\n\tif (output === OBJECT) {\n\t\treturn { value, symbol, exponent: 0, unit: symbol };\n\t}\n\n\treturn value + spacer + symbol;\n}\n\n/**\n * Optimized value calculation with bits handling\n * @param {number} num - Input number\n * @param {number} e - Exponent\n * @param {boolean} isDecimal - Whether to use decimal powers\n * @param {boolean} bits - Whether to calculate bits\n * @param {number} ceil - Ceiling value for auto-increment\n * @param {boolean} autoExponent - Whether exponent is auto (-1 or NaN)\n * @returns {Object} Object with result and e properties\n */\nexport function calculateOptimizedValue(num, e, isDecimal, bits, ceil, autoExponent = true) {\n\tlet d;\n\tif (isDecimal) {\n\t\td = DECIMAL_POWERS[e];\n\t} else {\n\t\td = BINARY_POWERS[e];\n\t}\n\tlet result = num / d;\n\n\tif (bits) {\n\t\tresult *= 8;\n\t\t// Handle auto-increment for bits (only when exponent is auto)\n\t\tif (autoExponent && result >= ceil && e < 8) {\n\t\t\tresult /= ceil;\n\t\t\te++;\n\t\t}\n\t}\n\n\treturn { result, e };\n}\n\n/**\n * Optimized precision handling with scientific notation correction\n * @param {number} value - Current value\n * @param {number} precision - Precision to apply\n * @param {number} e - Current exponent\n * @param {number} num - Original number\n * @param {boolean} isDecimal - Whether using decimal base\n * @param {boolean} bits - Whether calculating bits\n * @param {number} ceil - Ceiling value\n * @param {Function} roundingFunc - Rounding function\n * @param {number} round - Round value\n * @param {number} exponent - Forced exponent (-1 for auto)\n * @returns {Object} Object with value and e properties\n */\nexport function applyPrecisionHandling(\n\tvalue,\n\tprecision,\n\te,\n\tnum,\n\tisDecimal,\n\tbits,\n\tceil,\n\troundingFunc,\n\tround,\n\texponent,\n) {\n\tif (typeof value === \"string\") {\n\t\tvalue = parseFloat(value);\n\t}\n\n\tlet result = value.toPrecision(precision);\n\n\tconst autoExponent = exponent === -1 || isNaN(exponent);\n\n\t// Handle scientific notation by recalculating with incremented exponent\n\tif (result.includes(E) && e < 8 && autoExponent) {\n\t\te++;\n\t\tconst { result: valueResult } = calculateOptimizedValue(num, e, isDecimal, bits, ceil);\n\t\tlet p;\n\t\tif (round > 0) {\n\t\t\tp = Math.pow(10, round);\n\t\t} else {\n\t\t\tp = 1;\n\t\t}\n\t\tlet computed;\n\t\tif (p === 1) {\n\t\t\tcomputed = roundingFunc(valueResult);\n\t\t} else {\n\t\t\tcomputed = roundingFunc(valueResult * p) / p;\n\t\t}\n\t\tresult = computed.toPrecision(precision);\n\t}\n\n\treturn { value: result, e };\n}\n\n/**\n * Optimized number formatting with locale, separator, and padding\n * @param {number|string} value - Value to format\n * @param {string|boolean} locale - Locale setting\n * @param {Object} localeOptions - Locale options\n * @param {string} separator - Custom separator\n * @param {boolean} pad - Whether to pad\n * @param {number} round - Round value\n * @returns {string|number} Formatted value\n */\nexport function applyNumberFormatting(value, locale, localeOptions, separator, pad, round) {\n\tlet result = value;\n\n\t// Apply locale formatting\n\tif (locale === true) {\n\t\tresult = result.toLocaleString();\n\t} else if (locale.length > 0) {\n\t\tresult = result.toLocaleString(locale, localeOptions);\n\t} else if (separator.length > 0) {\n\t\tresult = result.toString().replace(PERIOD, separator);\n\t}\n\n\t// Apply padding\n\tif (pad && round > 0) {\n\t\tconst resultStr = result.toString();\n\t\tconst x = separator || (resultStr.slice(1).match(/[.,]/g) || []).pop() || PERIOD;\n\t\tconst tmp = resultStr.split(x);\n\t\tconst s = tmp[1] || EMPTY;\n\n\t\tconst l = s.length;\n\t\tconst n = round - l;\n\n\t\tresult = `${tmp[0]}${x}${s.padEnd(l + n, ZERO)}`;\n\t}\n\n\treturn result;\n}\n\n/**\n * Calculates exponent from the input value using pre-computed log values and clamps to supported range\n * Also adjusts precision when exponent exceeds the lookup table bounds\n * @param {number} num - Input file size in bytes\n * @param {number} e - Current exponent value\n * @param {number} exponent - Original user-provided exponent option (-1 for auto)\n * @param {boolean} isDecimal - Whether to use decimal (SI) base\n * @param {number} precision - Current precision value (modified when e > 8)\n * @returns {Object} Object with computed e value and possibly adjusted precision\n */\nexport function calculateExponent(num, e, exponent, isDecimal, precision) {\n\tif (e === -1 || isNaN(e)) {\n\t\tif (isDecimal) {\n\t\t\te = Math.floor(Math.log(num) / LOG_10_1000);\n\t\t} else {\n\t\t\te = Math.floor(Math.log(num) / LOG_2_1024);\n\t\t}\n\t\tif (e < 0) {\n\t\t\te = 0;\n\t\t}\n\t}\n\n\tif (e > 8) {\n\t\tif (precision > 0) {\n\t\t\tprecision += 8 - e;\n\t\t}\n\t\treturn { e: 8, precision };\n\t}\n\n\treturn { e, precision };\n}\n\n/**\n * Applies rounding to the raw calculated value and handles auto-increment ceiling\n * @param {number} val - Raw value before rounding\n * @param {number} ceil - Ceiling threshold (1000 for SI, 1024 for IEC)\n * @param {number} e - Current exponent value\n * @param {number} round - Number of decimal places\n * @param {Function} roundingFunc - Rounding method (Math.round, Math.floor, Math.ceil)\n * @param {boolean} autoExponent - Whether exponent is auto-calculated (-1 or NaN)\n * @returns {Object} Object with rounded value and possibly incremented exponent\n */\nexport function applyRounding(val, ceil, e, round, roundingFunc, autoExponent) {\n\tlet p;\n\tif (e > 0 && round > 0) {\n\t\tp = Math.pow(10, round);\n\t} else {\n\t\tp = 1;\n\t}\n\tlet r;\n\tif (p === 1) {\n\t\tr = roundingFunc(val);\n\t} else {\n\t\tr = roundingFunc(val * p) / p;\n\t}\n\n\tif (r === ceil && e < 8 && autoExponent) {\n\t\tr = 1;\n\t\te++;\n\t}\n\n\treturn { value: r, e };\n}\n\n/**\n * Resolves the unit symbol for the given standard, bits mode, and exponent\n * Handles SI standard special case where exponent 1 always uses \"kB\" or \"kbit\"\n * @param {string} actualStandard - The resolved standard (iec, jedec)\n * @param {boolean} bits - Whether formatting bit values\n * @param {number} e - Current exponent index\n * @param {boolean} isDecimal - Whether using decimal (SI) base\n * @returns {string} The resolved unit symbol string\n */\nexport function resolveSymbol(actualStandard, bits, e, isDecimal) {\n\tconst symbolTable = STRINGS.symbol[actualStandard][bits ? BITS : BYTES];\n\tlet result;\n\tif (isDecimal && e === 1) {\n\t\tif (bits) {\n\t\t\tresult = SI_KBIT;\n\t\t} else {\n\t\t\tresult = SI_KBYTE;\n\t\t}\n\t} else {\n\t\tresult = symbolTable[e];\n\t}\n\treturn result;\n}\n\n/**\n * Decorates the result: applies negation, custom symbols, number formatting, and full form names\n * Mutates the result array in-place for both value (index 0) and symbol (index 1)\n * @param {Array} result - Result array with numeric value at [0] and string symbol at [1]\n * @param {boolean} neg - Whether the original input was negative\n * @param {Object} symbols - Custom symbol override map\n * @param {string|boolean} locale - Locale string for formatting\n * @param {Object} localeOptions - Additional locale formatting options\n * @param {string} separator - Custom decimal separator\n * @param {boolean} pad - Whether zero-pad decimals\n * @param {number} round - Target decimal count for padding\n * @param {boolean} full - Whether to use full unit names\n * @param {Array} fullforms - Custom full unit name overrides\n * @param {string} actualStandard - Unit standard for full form lookup\n * @param {number} e - Current exponent index\n * @param {boolean} bits - Whether formatting bit values\n * @returns {void} Mutates result array in place\n */\nexport function decorateResult(\n\tresult,\n\tneg,\n\tsymbols,\n\tlocale,\n\tlocaleOptions,\n\tseparator,\n\tpad,\n\tround,\n\tfull,\n\tfullforms,\n\tactualStandard,\n\te,\n\tbits,\n) {\n\tif (neg) {\n\t\tresult[0] = -result[0];\n\t}\n\n\tif (symbols[result[1]]) {\n\t\tresult[1] = symbols[result[1]];\n\t}\n\n\tresult[0] = applyNumberFormatting(result[0], locale, localeOptions, separator, pad, round);\n\n\tif (full) {\n\t\tlet unit;\n\t\tif (bits) {\n\t\t\tunit = BIT;\n\t\t} else {\n\t\t\tunit = BYTE;\n\t\t}\n\t\tlet val;\n\t\tif (typeof result[0] === \"string\") {\n\t\t\tval = parseFloat(result[0]);\n\t\t} else {\n\t\t\tval = result[0];\n\t\t}\n\t\t// Determine singular/plural suffix\n\t\tlet suffix;\n\t\tif (val === 1) {\n\t\t\tsuffix = EMPTY;\n\t\t} else {\n\t\t\tsuffix = S;\n\t\t}\n\t\t// Determine symbol — custom fullforms are the complete name, defaults get unit+suffix\n\t\tif (fullforms[e]) {\n\t\t\tresult[1] = fullforms[e];\n\t\t} else {\n\t\t\tresult[1] = STRINGS.fullform[actualStandard][e] + unit + suffix;\n\t\t}\n\t}\n}\n\n/**\n * Formats the computed result array into the requested output type\n * @param {Array} result - Result array with formatted value at [0] and symbol at [1]\n * @param {number} e - Current exponent\n * @param {string} u - Original resolved symbol (before custom override)\n * @param {string} output - Output type (ARRAY, OBJECT, STRING)\n * @param {string} spacer - String separator between value and unit\n * @returns {string|Array|Object|number} Formatted result in requested type\n */\nexport function formatOutput(result, e, u, output, spacer) {\n\tif (output === ARRAY) {\n\t\treturn result;\n\t}\n\n\tif (output === OBJECT) {\n\t\treturn {\n\t\t\tvalue: result[0],\n\t\t\tsymbol: result[1],\n\t\t\texponent: e,\n\t\t\tunit: u,\n\t\t};\n\t}\n\n\tlet formatted;\n\tif (spacer === SPACE) {\n\t\tformatted = `${result[0]} ${result[1]}`;\n\t} else {\n\t\tformatted = result.join(spacer);\n\t}\n\treturn formatted;\n}\n","import {\n\tEMPTY,\n\tEXPONENT,\n\tFUNCTION,\n\tINVALID_NUMBER,\n\tINVALID_ROUND,\n\tROUND,\n\tSPACE,\n\tSTRING,\n} from \"./constants.js\";\nimport {\n\tapplyPrecisionHandling,\n\tapplyRounding,\n\tcalculateExponent,\n\tcalculateOptimizedValue,\n\tdecorateResult,\n\tformatOutput,\n\tgetBaseConfiguration,\n\thandleZeroValue,\n\tresolveSymbol,\n} from \"./helpers.js\";\n\n/**\n * Converts a file size in bytes to a human-readable string with appropriate units\n * @param {number|string|bigint} arg - The file size in bytes to convert\n * @param {Object} [options={}] - Configuration options for formatting\n * @param {boolean} [options.bits=false] - If true, calculates bits instead of bytes\n * @param {boolean} [options.pad=false] - If true, pads decimal places to match round parameter\n * @param {number} [options.base=-1] - Number base (2 for binary, 10 for decimal, -1 for auto)\n * @param {number} [options.round=2] - Number of decimal places to round to\n * @param {string|boolean} [options.locale=\"\"] - Locale for number formatting, true for system locale\n * @param {Object} [options.localeOptions={}] - Additional options for locale formatting\n * @param {string} [options.separator=\"\"] - Custom decimal separator\n * @param {string} [options.spacer=\" \"] - String to separate value and unit\n * @param {Object} [options.symbols={}] - Custom unit symbols\n * @param {string} [options.standard=\"\"] - Unit standard to use (SI, IEC, JEDEC)\n * @param {string} [options.output=\"string\"] - Output format: \"string\", \"array\", \"object\", or \"exponent\"\n * @param {boolean} [options.fullform=false] - If true, uses full unit names instead of abbreviations\n * @param {Array} [options.fullforms=[]] - Custom full unit names\n * @param {number} [options.exponent=-1] - Force specific exponent (-1 for auto)\n * @param {string} [options.roundingMethod=\"round\"] - Math rounding method to use\n * @param {number} [options.precision=0] - Number of significant digits (0 for auto)\n * @returns {string|Array|Object|number} Formatted file size based on output option\n * @throws {TypeError} When arg is not a valid number or roundingMethod is invalid\n * @example\n * filesize(1024) // \"1.02 kB\"\n * filesize(1024, {bits: true}) // \"8.19 kbit\"\n * filesize(1024, {output: \"object\"}) // {value: 1.02, symbol: \"kB\", exponent: 1, unit: \"kB\"}\n */\nexport function filesize(\n\targ,\n\t{\n\t\tbits = false,\n\t\tpad = false,\n\t\tbase = -1,\n\t\tround = 2,\n\t\tlocale = EMPTY,\n\t\tlocaleOptions = {},\n\t\tseparator = EMPTY,\n\t\tspacer = SPACE,\n\t\tsymbols = {},\n\t\tstandard = EMPTY,\n\t\toutput = STRING,\n\t\tfullform = false,\n\t\tfullforms = [],\n\t\texponent = -1,\n\t\troundingMethod = ROUND,\n\t\tprecision = 0,\n\t} = {},\n) {\n\tlet e = exponent,\n\t\tnum,\n\t\tresult = [],\n\t\tval = 0,\n\t\tu = EMPTY;\n\n\tif (typeof arg === \"bigint\") {\n\t\tnum = Number(arg);\n\t} else {\n\t\tnum = Number(arg);\n\n\t\tif (isNaN(arg)) {\n\t\t\tthrow new TypeError(INVALID_NUMBER);\n\t\t}\n\n\t\tif (!isFinite(num)) {\n\t\t\tthrow new TypeError(INVALID_NUMBER);\n\t\t}\n\t}\n\n\tconst { isDecimal, ceil, actualStandard } = getBaseConfiguration(standard, base);\n\n\tconst full = fullform === true,\n\t\tneg = num < 0,\n\t\troundingFunc = Math[roundingMethod];\n\n\tif (typeof roundingFunc !== FUNCTION) {\n\t\tthrow new TypeError(INVALID_ROUND);\n\t}\n\n\tif (neg) {\n\t\tnum = -num;\n\t}\n\n\tif (num === 0) {\n\t\treturn handleZeroValue(\n\t\t\tprecision,\n\t\t\tactualStandard,\n\t\t\tbits,\n\t\t\tsymbols,\n\t\t\tfull,\n\t\t\tfullforms,\n\t\t\toutput,\n\t\t\tspacer,\n\t\t);\n\t}\n\n\t// Exponent calculation + clamp + precision adjustment\n\tconst { e: calculatedE, precision: precisionAdjusted } = calculateExponent(\n\t\tnum,\n\t\te,\n\t\texponent,\n\t\tisDecimal,\n\t\tprecision,\n\t);\n\te = calculatedE;\n\tconst autoExponent = exponent === -1 || isNaN(exponent);\n\n\tif (output === EXPONENT) {\n\t\treturn e;\n\t}\n\n\tconst { result: valueResult, e: valueExponent } = calculateOptimizedValue(\n\t\tnum,\n\t\te,\n\t\tisDecimal,\n\t\tbits,\n\t\tceil,\n\t\tautoExponent,\n\t);\n\tval = valueResult;\n\te = valueExponent;\n\n\t// Rounding + auto-increment ceiling\n\tconst rounded = applyRounding(val, ceil, e, round, roundingFunc, autoExponent);\n\tresult[0] = rounded.value;\n\te = rounded.e;\n\n\t// Precision handling\n\tif (precisionAdjusted > 0) {\n\t\tconst precisionResult = applyPrecisionHandling(\n\t\t\tresult[0],\n\t\t\tprecisionAdjusted,\n\t\t\te,\n\t\t\tnum,\n\t\t\tisDecimal,\n\t\t\tbits,\n\t\t\tceil,\n\t\t\troundingFunc,\n\t\t\tround,\n\t\t\texponent,\n\t\t);\n\t\tresult[0] = precisionResult.value;\n\t\te = precisionResult.e;\n\t}\n\n\tu = resolveSymbol(actualStandard, bits, e, isDecimal);\n\tresult[1] = u;\n\n\tdecorateResult(\n\t\tresult,\n\t\tneg,\n\t\tsymbols,\n\t\tlocale,\n\t\tlocaleOptions,\n\t\tseparator,\n\t\tpad,\n\t\tround,\n\t\tfull,\n\t\tfullforms,\n\t\tactualStandard,\n\t\te,\n\t\tbits,\n\t);\n\n\treturn formatOutput(result, e, u, output, spacer);\n}\n\n/**\n * Creates a partially applied version of filesize with preset options\n * @param {Object} [options={}] - Configuration options (same as filesize)\n * @param {boolean} [options.bits=false] - If true, calculates bits instead of bytes\n * @param {boolean} [options.pad=false] - If true, pads decimal places to match round parameter\n * @param {number} [options.base=-1] - Number base (2 for binary, 10 for decimal, -1 for auto)\n * @param {number} [options.round=2] - Number of decimal places to round to\n * @param {string|boolean} [options.locale=\"\"] - Locale for number formatting, true for system locale\n * @param {Object} [options.localeOptions={}] - Additional options for locale formatting\n * @param {string} [options.separator=\"\"] - Custom decimal separator\n * @param {string} [options.spacer=\" \"] - String to separate value and unit\n * @param {Object} [options.symbols={}] - Custom unit symbols\n * @param {string} [options.standard=\"\"] - Unit standard to use (SI, IEC, JEDEC)\n * @param {string} [options.output=\"string\"] - Output format: \"string\", \"array\", \"object\", or \"exponent\"\n * @param {boolean} [options.fullform=false] - If true, uses full unit names instead of abbreviations\n * @param {Array} [options.fullforms=[]] - Custom full unit names\n * @param {number} [options.exponent=-1] - Force specific exponent (-1 for auto)\n * @param {string} [options.roundingMethod=\"round\"] - Math rounding method to use\n * @param {number} [options.precision=0] - Number of significant digits (0 for auto)\n * @returns {Function} A function that takes a file size and returns formatted output\n * @example\n * const formatBytes = partial({round: 1, standard: \"iec\"});\n * formatBytes(1024) // \"1 KiB\"\n * formatBytes(2048) // \"2 KiB\"\n * formatBytes(1536) // \"1.5 KiB\"\n */\nexport function partial({\n\tbits = false,\n\tpad = false,\n\tbase = -1,\n\tround = 2,\n\tlocale = EMPTY,\n\tseparator = EMPTY,\n\tspacer = SPACE,\n\tstandard = EMPTY,\n\toutput = STRING,\n\tfullform = false,\n\texponent = -1,\n\troundingMethod = ROUND,\n\tprecision = 0,\n\tlocaleOptions = {},\n\tsymbols = {},\n\tfullforms = [],\n} = {}) {\n\tconst cloned = {\n\t\tlocaleOptions: JSON.parse(JSON.stringify(localeOptions)),\n\t\tsymbols: JSON.parse(JSON.stringify(symbols)),\n\t\tfullforms: JSON.parse(JSON.stringify(fullforms)),\n\t};\n\n\treturn (arg) =>\n\t\tfilesize(arg, {\n\t\t\tbits,\n\t\t\tpad,\n\t\t\tbase,\n\t\t\tround,\n\t\t\tlocale,\n\t\t\tlocaleOptions: cloned.localeOptions,\n\t\t\tseparator,\n\t\t\tspacer,\n\t\t\tsymbols: cloned.symbols,\n\t\t\tstandard,\n\t\t\toutput,\n\t\t\tfullform,\n\t\t\tfullforms: cloned.fullforms,\n\t\t\texponent,\n\t\t\troundingMethod,\n\t\t\tprecision,\n\t\t});\n}\n"],"names":["INVALID_NUMBER","IEC","JEDEC","SI","BYTE","ARRAY","OBJECT","STRING","EXPONENT","ROUND","STRINGS","symbol","iec","bits","bytes","jedec","fullform","BINARY_POWERS","DECIMAL_POWERS","LOG_2_1024","Math","log","LOG_10_1000","STANDARD_CONFIGS","isDecimal","ceil","actualStandard","calculateOptimizedValue","num","e","autoExponent","d","result","filesize","arg","pad","base","round","locale","EMPTY","localeOptions","separator","spacer","symbols","standard","output","fullforms","exponent","roundingMethod","precision","val","u","Number","isNaN","TypeError","isFinite","getBaseConfiguration","full","neg","roundingFunc","value","toPrecision","unit","handleZeroValue","calculatedE","precisionAdjusted","floor","calculateExponent","valueResult","valueExponent","rounded","p","r","pow","applyRounding","precisionResult","parseFloat","includes","computed","applyPrecisionHandling","symbolTable","resolveSymbol","toLocaleString","length","toString","replace","resultStr","x","slice","match","pop","tmp","split","s","l","n","padEn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AhB,cAAAsE"} +{"version":3,"file":"filesize.min.js","sources":["../src/constants.js","../src/helpers.js","../src/filesize.js"],"sourcesContent":["// Error Messages\nexport const INVALID_NUMBER = \"Invalid number\";\nexport const INVALID_ROUND = \"Invalid rounding method\";\n\n// Standard Types\nexport const IEC = \"iec\";\nexport const JEDEC = \"jedec\";\nexport const SI = \"si\";\n\n// Unit Types\nexport const BIT = \"bit\";\nexport const BITS = \"bits\";\nexport const BYTE = \"byte\";\nexport const BYTES = \"bytes\";\nexport const SI_KBIT = \"kbit\";\nexport const SI_KBYTE = \"kB\";\n\n// Output Format Types\nexport const ARRAY = \"array\";\nexport const FUNCTION = \"function\";\nexport const OBJECT = \"object\";\nexport const STRING = \"string\";\n\n// Processing Constants\nexport const EXPONENT = \"exponent\";\nexport const ROUND = \"round\";\n\n// Special Characters and Values\nexport const E = \"e\";\nexport const EMPTY = \"\";\nexport const PERIOD = \".\";\nexport const S = \"s\";\nexport const SPACE = \" \";\nexport const ZERO = \"0\";\n\n// Data Structures\nexport const STRINGS = {\n\tsymbol: {\n\t\tiec: {\n\t\t\tbits: [\"bit\", \"Kibit\", \"Mibit\", \"Gibit\", \"Tibit\", \"Pibit\", \"Eibit\", \"Zibit\", \"Yibit\"],\n\t\t\tbytes: [\"B\", \"KiB\", \"MiB\", \"GiB\", \"TiB\", \"PiB\", \"EiB\", \"ZiB\", \"YiB\"],\n\t\t},\n\t\tjedec: {\n\t\t\tbits: [\"bit\", \"Kbit\", \"Mbit\", \"Gbit\", \"Tbit\", \"Pbit\", \"Ebit\", \"Zbit\", \"Ybit\"],\n\t\t\tbytes: [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"],\n\t\t},\n\t},\n\tfullform: {\n\t\tiec: [\"\", \"kibi\", \"mebi\", \"gibi\", \"tebi\", \"pebi\", \"exbi\", \"zebi\", \"yobi\"],\n\t\tjedec: [\"\", \"kilo\", \"mega\", \"giga\", \"tera\", \"peta\", \"exa\", \"zetta\", \"yotta\"],\n\t},\n};\n\n// Pre-computed lookup tables for performance optimization\nexport const BINARY_POWERS = [\n\t1, // 2^0\n\t1024, // 2^10\n\t1048576, // 2^20\n\t1073741824, // 2^30\n\t1099511627776, // 2^40\n\t1125899906842624, // 2^50\n\t1152921504606846976, // 2^60\n\t1180591620717411303424, // 2^70\n\t1208925819614629174706176, // 2^80\n];\n\nexport const DECIMAL_POWERS = [\n\t1, // 10^0\n\t1000, // 10^3\n\t1000000, // 10^6\n\t1000000000, // 10^9\n\t1000000000000, // 10^12\n\t1000000000000000, // 10^15\n\t1000000000000000000, // 10^18\n\t1000000000000000000000, // 10^21\n\t1000000000000000000000000, // 10^24\n];\n\n// Pre-computed log values for faster exponent calculation\nexport const LOG_2_1024 = Math.log(1024);\nexport const LOG_10_1000 = Math.log(1000);\n","import {\n\tARRAY,\n\tBINARY_POWERS,\n\tBIT,\n\tBITS,\n\tBYTE,\n\tBYTES,\n\tDECIMAL_POWERS,\n\tE,\n\tEMPTY,\n\tEXPONENT,\n\tIEC,\n\tJEDEC,\n\tLOG_10_1000,\n\tLOG_2_1024,\n\tOBJECT,\n\tPERIOD,\n\tS,\n\tSI,\n\tSI_KBIT,\n\tSI_KBYTE,\n\tSPACE,\n\tSTRINGS,\n\tZERO,\n} from \"./constants.js\";\n\n// Cached configuration lookup for better performance\nconst STANDARD_CONFIGS = {\n\t[SI]: { isDecimal: true, ceil: 1000, actualStandard: JEDEC },\n\t[IEC]: { isDecimal: false, ceil: 1024, actualStandard: IEC },\n\t[JEDEC]: { isDecimal: false, ceil: 1024, actualStandard: JEDEC },\n};\n\n/**\n * Optimized base configuration lookup\n * @param {string} standard - Standard type\n * @param {number} base - Base number\n * @returns {Object} Configuration object\n */\nexport function getBaseConfiguration(standard, base) {\n\t// Use cached lookup table for better performance\n\tif (STANDARD_CONFIGS[standard]) {\n\t\treturn STANDARD_CONFIGS[standard];\n\t}\n\n\t// Base override\n\tif (base === 2) {\n\t\treturn { isDecimal: false, ceil: 1024, actualStandard: IEC };\n\t}\n\n\t// Default\n\treturn { isDecimal: true, ceil: 1000, actualStandard: JEDEC };\n}\n\n/**\n * Optimized zero value handling\n * @param {number} precision - Precision value\n * @param {string} actualStandard - Standard to use\n * @param {boolean} bits - Whether to use bits\n * @param {Object} symbols - Custom symbols\n * @param {boolean} full - Whether to use full form\n * @param {Array} fullforms - Custom full forms\n * @param {string} output - Output format\n * @param {string} spacer - Spacer character\n * @param {string} [symbol] - Symbol to use (defaults based on bits/standard)\n * @returns {string|Array|Object|number} Formatted result\n */\nexport function handleZeroValue(\n\tprecision,\n\tactualStandard,\n\tbits,\n\tsymbols,\n\tfull,\n\tfullforms,\n\toutput,\n\tspacer,\n\tsymbol,\n) {\n\tlet value;\n\tif (precision > 0) {\n\t\tvalue = (0).toPrecision(precision);\n\t} else {\n\t\tvalue = 0;\n\t}\n\n\tif (output === EXPONENT) {\n\t\treturn 0;\n\t}\n\n\t// Set default symbol if not provided\n\tif (!symbol) {\n\t\tsymbol = bits\n\t\t\t? STRINGS.symbol[actualStandard].bits[0]\n\t\t\t: STRINGS.symbol[actualStandard].bytes[0];\n\t}\n\n\t// Apply symbol customization\n\tif (symbols[symbol]) {\n\t\tsymbol = symbols[symbol];\n\t}\n\n\t// Apply full form\n\tif (full) {\n\t\tif (fullforms[0]) {\n\t\t\tsymbol = fullforms[0];\n\t\t} else {\n\t\t\tsymbol = STRINGS.fullform[actualStandard][0];\n\t\t\tif (bits) {\n\t\t\t\tsymbol += BIT;\n\t\t\t} else {\n\t\t\t\tsymbol += BYTE;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return in requested format\n\tif (output === ARRAY) {\n\t\treturn [value, symbol];\n\t}\n\n\tif (output === OBJECT) {\n\t\treturn { value, symbol, exponent: 0, unit: symbol };\n\t}\n\n\treturn value + spacer + symbol;\n}\n\n/**\n * Optimized value calculation with bits handling\n * @param {number} num - Input number\n * @param {number} e - Exponent\n * @param {boolean} isDecimal - Whether to use decimal powers\n * @param {boolean} bits - Whether to calculate bits\n * @param {number} ceil - Ceiling value for auto-increment\n * @param {boolean} autoExponent - Whether exponent is auto (-1 or NaN)\n * @returns {Object} Object with result and e properties\n */\nexport function calculateOptimizedValue(num, e, isDecimal, bits, ceil, autoExponent = true) {\n\tlet d;\n\tif (isDecimal) {\n\t\td = DECIMAL_POWERS[e];\n\t} else {\n\t\td = BINARY_POWERS[e];\n\t}\n\tlet result = num / d;\n\n\tif (bits) {\n\t\tresult *= 8;\n\t\t// Handle auto-increment for bits (only when exponent is auto)\n\t\tif (autoExponent && result >= ceil && e < 8) {\n\t\t\tresult /= ceil;\n\t\t\te++;\n\t\t}\n\t}\n\n\treturn { result, e };\n}\n\n/**\n * Optimized precision handling with scientific notation correction\n * @param {number} value - Current value\n * @param {number} precision - Precision to apply\n * @param {number} e - Current exponent\n * @param {number} num - Original number\n * @param {boolean} isDecimal - Whether using decimal base\n * @param {boolean} bits - Whether calculating bits\n * @param {number} ceil - Ceiling value\n * @param {Function} roundingFunc - Rounding function\n * @param {number} round - Round value\n * @param {number} exponent - Forced exponent (-1 for auto)\n * @returns {Object} Object with value and e properties\n */\nexport function applyPrecisionHandling(\n\tvalue,\n\tprecision,\n\te,\n\tnum,\n\tisDecimal,\n\tbits,\n\tceil,\n\troundingFunc,\n\tround,\n\texponent,\n) {\n\tif (typeof value === \"string\") {\n\t\tvalue = parseFloat(value);\n\t}\n\n\tlet result = value.toPrecision(precision);\n\n\tconst autoExponent = exponent === -1 || isNaN(exponent);\n\n\t// Handle scientific notation by recalculating with incremented exponent\n\tif (result.includes(E) && e < 8 && autoExponent) {\n\t\te++;\n\t\tconst { result: valueResult } = calculateOptimizedValue(num, e, isDecimal, bits, ceil);\n\t\tlet p;\n\t\tif (round > 0) {\n\t\t\tp = Math.pow(10, round);\n\t\t} else {\n\t\t\tp = 1;\n\t\t}\n\t\tlet computed;\n\t\tif (p === 1) {\n\t\t\tcomputed = roundingFunc(valueResult);\n\t\t} else {\n\t\t\tcomputed = roundingFunc(valueResult * p) / p;\n\t\t}\n\t\tresult = computed.toPrecision(precision);\n\t}\n\n\treturn { value: result, e };\n}\n\n/**\n * Optimized number formatting with locale, separator, and padding\n * @param {number|string} value - Value to format\n * @param {string|boolean} locale - Locale setting\n * @param {Object} localeOptions - Locale options\n * @param {string} separator - Custom separator\n * @param {boolean} pad - Whether to pad\n * @param {number} round - Round value\n * @returns {string|number} Formatted value\n */\nexport function applyNumberFormatting(value, locale, localeOptions, separator, pad, round) {\n\tlet result = value;\n\n\t// When padding alongside a locale, let the locale formatter emit the fixed\n\t// number of fraction digits. The manual string padding below cannot tell a\n\t// locale-inserted grouping separator from the decimal separator, so it\n\t// dropped digits (e.g. \"1,234,500\" became \"1,234\").\n\tconst localePad =\n\t\tpad && round > 0 ? { minimumFractionDigits: round, maximumFractionDigits: round } : undefined;\n\n\t// Apply locale formatting\n\tif (locale === true) {\n\t\tresult = result.toLocaleString(undefined, localePad);\n\t} else if (locale.length > 0) {\n\t\tresult = result.toLocaleString(locale, { ...localeOptions, ...localePad });\n\t} else if (separator.length > 0) {\n\t\tresult = result.toString().replace(PERIOD, separator);\n\t}\n\n\t// Apply padding for the non-locale paths, where the string has a single\n\t// decimal separator and no grouping is inserted.\n\tif (pad && round > 0 && locale !== true && locale.length === 0) {\n\t\tconst resultStr = result.toString();\n\t\tconst x = separator || PERIOD;\n\t\tconst tmp = resultStr.split(x);\n\t\tconst s = tmp[1] || EMPTY;\n\n\t\tresult = `${tmp[0]}${x}${s.padEnd(round, ZERO)}`;\n\t}\n\n\treturn result;\n}\n\n/**\n * Calculates exponent from the input value using pre-computed log values and clamps to supported range\n * Also adjusts precision when exponent exceeds the lookup table bounds\n * @param {number} num - Input file size in bytes\n * @param {number} e - Current exponent value\n * @param {number} exponent - Original user-provided exponent option (-1 for auto)\n * @param {boolean} isDecimal - Whether to use decimal (SI) base\n * @param {number} precision - Current precision value (modified when e > 8)\n * @returns {Object} Object with computed e value and possibly adjusted precision\n */\nexport function calculateExponent(num, e, exponent, isDecimal, precision) {\n\tif (e === -1 || isNaN(e)) {\n\t\tif (isDecimal) {\n\t\t\te = Math.floor(Math.log(num) / LOG_10_1000);\n\t\t} else {\n\t\t\te = Math.floor(Math.log(num) / LOG_2_1024);\n\t\t}\n\t\tif (e < 0) {\n\t\t\te = 0;\n\t\t}\n\t}\n\n\tif (e > 8) {\n\t\tif (precision > 0) {\n\t\t\tprecision += 8 - e;\n\t\t}\n\t\treturn { e: 8, precision };\n\t}\n\n\treturn { e, precision };\n}\n\n/**\n * Applies rounding to the raw calculated value and handles auto-increment ceiling\n * @param {number} val - Raw value before rounding\n * @param {number} ceil - Ceiling threshold (1000 for SI, 1024 for IEC)\n * @param {number} e - Current exponent value\n * @param {number} round - Number of decimal places\n * @param {Function} roundingFunc - Rounding method (Math.round, Math.floor, Math.ceil)\n * @param {boolean} autoExponent - Whether exponent is auto-calculated (-1 or NaN)\n * @returns {Object} Object with rounded value and possibly incremented exponent\n */\nexport function applyRounding(val, ceil, e, round, roundingFunc, autoExponent) {\n\tlet p;\n\tif (e > 0 && round > 0) {\n\t\tp = Math.pow(10, round);\n\t} else {\n\t\tp = 1;\n\t}\n\tlet r;\n\tif (p === 1) {\n\t\tr = roundingFunc(val);\n\t} else {\n\t\tr = roundingFunc(val * p) / p;\n\t}\n\n\tif (r === ceil && e < 8 && autoExponent) {\n\t\tr = 1;\n\t\te++;\n\t}\n\n\treturn { value: r, e };\n}\n\n/**\n * Resolves the unit symbol for the given standard, bits mode, and exponent\n * Handles SI standard special case where exponent 1 always uses \"kB\" or \"kbit\"\n * @param {string} actualStandard - The resolved standard (iec, jedec)\n * @param {boolean} bits - Whether formatting bit values\n * @param {number} e - Current exponent index\n * @param {boolean} isDecimal - Whether using decimal (SI) base\n * @returns {string} The resolved unit symbol string\n */\nexport function resolveSymbol(actualStandard, bits, e, isDecimal) {\n\tconst symbolTable = STRINGS.symbol[actualStandard][bits ? BITS : BYTES];\n\tlet result;\n\tif (isDecimal && e === 1) {\n\t\tif (bits) {\n\t\t\tresult = SI_KBIT;\n\t\t} else {\n\t\t\tresult = SI_KBYTE;\n\t\t}\n\t} else {\n\t\tresult = symbolTable[e];\n\t}\n\treturn result;\n}\n\n/**\n * Decorates the result: applies negation, custom symbols, number formatting, and full form names\n * Mutates the result array in-place for both value (index 0) and symbol (index 1)\n * @param {Array} result - Result array with numeric value at [0] and string symbol at [1]\n * @param {boolean} neg - Whether the original input was negative\n * @param {Object} symbols - Custom symbol override map\n * @param {string|boolean} locale - Locale string for formatting\n * @param {Object} localeOptions - Additional locale formatting options\n * @param {string} separator - Custom decimal separator\n * @param {boolean} pad - Whether zero-pad decimals\n * @param {number} round - Target decimal count for padding\n * @param {boolean} full - Whether to use full unit names\n * @param {Array} fullforms - Custom full unit name overrides\n * @param {string} actualStandard - Unit standard for full form lookup\n * @param {number} e - Current exponent index\n * @param {boolean} bits - Whether formatting bit values\n * @returns {void} Mutates result array in place\n */\nexport function decorateResult(\n\tresult,\n\tneg,\n\tsymbols,\n\tlocale,\n\tlocaleOptions,\n\tseparator,\n\tpad,\n\tround,\n\tfull,\n\tfullforms,\n\tactualStandard,\n\te,\n\tbits,\n) {\n\tif (neg) {\n\t\tresult[0] = -result[0];\n\t}\n\n\tif (symbols[result[1]]) {\n\t\tresult[1] = symbols[result[1]];\n\t}\n\n\tresult[0] = applyNumberFormatting(result[0], locale, localeOptions, separator, pad, round);\n\n\tif (full) {\n\t\tlet unit;\n\t\tif (bits) {\n\t\t\tunit = BIT;\n\t\t} else {\n\t\t\tunit = BYTE;\n\t\t}\n\t\tlet val;\n\t\tif (typeof result[0] === \"string\") {\n\t\t\tval = parseFloat(result[0]);\n\t\t} else {\n\t\t\tval = result[0];\n\t\t}\n\t\t// Determine singular/plural suffix\n\t\tlet suffix;\n\t\tif (val === 1) {\n\t\t\tsuffix = EMPTY;\n\t\t} else {\n\t\t\tsuffix = S;\n\t\t}\n\t\t// Determine symbol — custom fullforms are the complete name, defaults get unit+suffix\n\t\tif (fullforms[e]) {\n\t\t\tresult[1] = fullforms[e];\n\t\t} else {\n\t\t\tresult[1] = STRINGS.fullform[actualStandard][e] + unit + suffix;\n\t\t}\n\t}\n}\n\n/**\n * Formats the computed result array into the requested output type\n * @param {Array} result - Result array with formatted value at [0] and symbol at [1]\n * @param {number} e - Current exponent\n * @param {string} u - Original resolved symbol (before custom override)\n * @param {string} output - Output type (ARRAY, OBJECT, STRING)\n * @param {string} spacer - String separator between value and unit\n * @returns {string|Array|Object|number} Formatted result in requested type\n */\nexport function formatOutput(result, e, u, output, spacer) {\n\tif (output === ARRAY) {\n\t\treturn result;\n\t}\n\n\tif (output === OBJECT) {\n\t\treturn {\n\t\t\tvalue: result[0],\n\t\t\tsymbol: result[1],\n\t\t\texponent: e,\n\t\t\tunit: u,\n\t\t};\n\t}\n\n\tlet formatted;\n\tif (spacer === SPACE) {\n\t\tformatted = `${result[0]} ${result[1]}`;\n\t} else {\n\t\tformatted = result.join(spacer);\n\t}\n\treturn formatted;\n}\n","import {\n\tEMPTY,\n\tEXPONENT,\n\tFUNCTION,\n\tINVALID_NUMBER,\n\tINVALID_ROUND,\n\tROUND,\n\tSPACE,\n\tSTRING,\n} from \"./constants.js\";\nimport {\n\tapplyPrecisionHandling,\n\tapplyRounding,\n\tcalculateExponent,\n\tcalculateOptimizedValue,\n\tdecorateResult,\n\tformatOutput,\n\tgetBaseConfiguration,\n\thandleZeroValue,\n\tresolveSymbol,\n} from \"./helpers.js\";\n\n/**\n * Converts a file size in bytes to a human-readable string with appropriate units\n * @param {number|string|bigint} arg - The file size in bytes to convert\n * @param {Object} [options={}] - Configuration options for formatting\n * @param {boolean} [options.bits=false] - If true, calculates bits instead of bytes\n * @param {boolean} [options.pad=false] - If true, pads decimal places to match round parameter\n * @param {number} [options.base=-1] - Number base (2 for binary, 10 for decimal, -1 for auto)\n * @param {number} [options.round=2] - Number of decimal places to round to\n * @param {string|boolean} [options.locale=\"\"] - Locale for number formatting, true for system locale\n * @param {Object} [options.localeOptions={}] - Additional options for locale formatting\n * @param {string} [options.separator=\"\"] - Custom decimal separator\n * @param {string} [options.spacer=\" \"] - String to separate value and unit\n * @param {Object} [options.symbols={}] - Custom unit symbols\n * @param {string} [options.standard=\"\"] - Unit standard to use (SI, IEC, JEDEC)\n * @param {string} [options.output=\"string\"] - Output format: \"string\", \"array\", \"object\", or \"exponent\"\n * @param {boolean} [options.fullform=false] - If true, uses full unit names instead of abbreviations\n * @param {Array} [options.fullforms=[]] - Custom full unit names\n * @param {number} [options.exponent=-1] - Force specific exponent (-1 for auto)\n * @param {string} [options.roundingMethod=\"round\"] - Math rounding method to use\n * @param {number} [options.precision=0] - Number of significant digits (0 for auto)\n * @returns {string|Array|Object|number} Formatted file size based on output option\n * @throws {TypeError} When arg is not a valid number or roundingMethod is invalid\n * @example\n * filesize(1024) // \"1.02 kB\"\n * filesize(1024, {bits: true}) // \"8.19 kbit\"\n * filesize(1024, {output: \"object\"}) // {value: 1.02, symbol: \"kB\", exponent: 1, unit: \"kB\"}\n */\nexport function filesize(\n\targ,\n\t{\n\t\tbits = false,\n\t\tpad = false,\n\t\tbase = -1,\n\t\tround = 2,\n\t\tlocale = EMPTY,\n\t\tlocaleOptions = {},\n\t\tseparator = EMPTY,\n\t\tspacer = SPACE,\n\t\tsymbols = {},\n\t\tstandard = EMPTY,\n\t\toutput = STRING,\n\t\tfullform = false,\n\t\tfullforms = [],\n\t\texponent = -1,\n\t\troundingMethod = ROUND,\n\t\tprecision = 0,\n\t} = {},\n) {\n\tlet e = exponent,\n\t\tnum,\n\t\tresult = [],\n\t\tval = 0,\n\t\tu = EMPTY;\n\n\tif (typeof arg === \"bigint\") {\n\t\tnum = Number(arg);\n\t} else {\n\t\tnum = Number(arg);\n\n\t\tif (isNaN(arg)) {\n\t\t\tthrow new TypeError(INVALID_NUMBER);\n\t\t}\n\n\t\tif (!isFinite(num)) {\n\t\t\tthrow new TypeError(INVALID_NUMBER);\n\t\t}\n\t}\n\n\tconst { isDecimal, ceil, actualStandard } = getBaseConfiguration(standard, base);\n\n\tconst full = fullform === true,\n\t\tneg = num < 0,\n\t\troundingFunc = Math[roundingMethod];\n\n\tif (typeof roundingFunc !== FUNCTION) {\n\t\tthrow new TypeError(INVALID_ROUND);\n\t}\n\n\tif (neg) {\n\t\tnum = -num;\n\t}\n\n\tif (num === 0) {\n\t\treturn handleZeroValue(\n\t\t\tprecision,\n\t\t\tactualStandard,\n\t\t\tbits,\n\t\t\tsymbols,\n\t\t\tfull,\n\t\t\tfullforms,\n\t\t\toutput,\n\t\t\tspacer,\n\t\t);\n\t}\n\n\t// Exponent calculation + clamp + precision adjustment\n\tconst { e: calculatedE, precision: precisionAdjusted } = calculateExponent(\n\t\tnum,\n\t\te,\n\t\texponent,\n\t\tisDecimal,\n\t\tprecision,\n\t);\n\te = calculatedE;\n\tconst autoExponent = exponent === -1 || isNaN(exponent);\n\n\tif (output === EXPONENT) {\n\t\treturn e;\n\t}\n\n\tconst { result: valueResult, e: valueExponent } = calculateOptimizedValue(\n\t\tnum,\n\t\te,\n\t\tisDecimal,\n\t\tbits,\n\t\tceil,\n\t\tautoExponent,\n\t);\n\tval = valueResult;\n\te = valueExponent;\n\n\t// Rounding + auto-increment ceiling\n\tconst rounded = applyRounding(val, ceil, e, round, roundingFunc, autoExponent);\n\tresult[0] = rounded.value;\n\te = rounded.e;\n\n\t// Precision handling\n\tif (precisionAdjusted > 0) {\n\t\tconst precisionResult = applyPrecisionHandling(\n\t\t\tresult[0],\n\t\t\tprecisionAdjusted,\n\t\t\te,\n\t\t\tnum,\n\t\t\tisDecimal,\n\t\t\tbits,\n\t\t\tceil,\n\t\t\troundingFunc,\n\t\t\tround,\n\t\t\texponent,\n\t\t);\n\t\tresult[0] = precisionResult.value;\n\t\te = precisionResult.e;\n\t}\n\n\tu = resolveSymbol(actualStandard, bits, e, isDecimal);\n\tresult[1] = u;\n\n\tdecorateResult(\n\t\tresult,\n\t\tneg,\n\t\tsymbols,\n\t\tlocale,\n\t\tlocaleOptions,\n\t\tseparator,\n\t\tpad,\n\t\tround,\n\t\tfull,\n\t\tfullforms,\n\t\tactualStandard,\n\t\te,\n\t\tbits,\n\t);\n\n\treturn formatOutput(result, e, u, output, spacer);\n}\n\n/**\n * Creates a partially applied version of filesize with preset options\n * @param {Object} [options={}] - Configuration options (same as filesize)\n * @param {boolean} [options.bits=false] - If true, calculates bits instead of bytes\n * @param {boolean} [options.pad=false] - If true, pads decimal places to match round parameter\n * @param {number} [options.base=-1] - Number base (2 for binary, 10 for decimal, -1 for auto)\n * @param {number} [options.round=2] - Number of decimal places to round to\n * @param {string|boolean} [options.locale=\"\"] - Locale for number formatting, true for system locale\n * @param {Object} [options.localeOptions={}] - Additional options for locale formatting\n * @param {string} [options.separator=\"\"] - Custom decimal separator\n * @param {string} [options.spacer=\" \"] - String to separate value and unit\n * @param {Object} [options.symbols={}] - Custom unit symbols\n * @param {string} [options.standard=\"\"] - Unit standard to use (SI, IEC, JEDEC)\n * @param {string} [options.output=\"string\"] - Output format: \"string\", \"array\", \"object\", or \"exponent\"\n * @param {boolean} [options.fullform=false] - If true, uses full unit names instead of abbreviations\n * @param {Array} [options.fullforms=[]] - Custom full unit names\n * @param {number} [options.exponent=-1] - Force specific exponent (-1 for auto)\n * @param {string} [options.roundingMethod=\"round\"] - Math rounding method to use\n * @param {number} [options.precision=0] - Number of significant digits (0 for auto)\n * @returns {Function} A function that takes a file size and returns formatted output\n * @example\n * const formatBytes = partial({round: 1, standard: \"iec\"});\n * formatBytes(1024) // \"1 KiB\"\n * formatBytes(2048) // \"2 KiB\"\n * formatBytes(1536) // \"1.5 KiB\"\n */\nexport function partial({\n\tbits = false,\n\tpad = false,\n\tbase = -1,\n\tround = 2,\n\tlocale = EMPTY,\n\tseparator = EMPTY,\n\tspacer = SPACE,\n\tstandard = EMPTY,\n\toutput = STRING,\n\tfullform = false,\n\texponent = -1,\n\troundingMethod = ROUND,\n\tprecision = 0,\n\tlocaleOptions = {},\n\tsymbols = {},\n\tfullforms = [],\n} = {}) {\n\tconst cloned = {\n\t\tlocaleOptions: JSON.parse(JSON.stringify(localeOptions)),\n\t\tsymbols: JSON.parse(JSON.stringify(symbols)),\n\t\tfullforms: JSON.parse(JSON.stringify(fullforms)),\n\t};\n\n\treturn (arg) =>\n\t\tfilesize(arg, {\n\t\t\tbits,\n\t\t\tpad,\n\t\t\tbase,\n\t\t\tround,\n\t\t\tlocale,\n\t\t\tlocaleOptions: cloned.localeOptions,\n\t\t\tseparator,\n\t\t\tspacer,\n\t\t\tsymbols: cloned.symbols,\n\t\t\tstandard,\n\t\t\toutput,\n\t\t\tfullform,\n\t\t\tfullforms: cloned.fullforms,\n\t\t\texponent,\n\t\t\troundingMethod,\n\t\t\tprecision,\n\t\t});\n}\n"],"names":["INVALID_NUMBER","IEC","JEDEC","SI","BYTE","ARRAY","OBJECT","STRING","EXPONENT","ROUND","STRINGS","symbol","iec","bits","bytes","jedec","fullform","BINARY_POWERS","DECIMAL_POWERS","LOG_2_1024","Math","log","LOG_10_1000","STANDARD_CONFIGS","isDecimal","ceil","actualStandard","calculateOptimizedValue","num","e","autoExponent","d","result","filesize","arg","pad","base","round","locale","EMPTY","localeOptions","separator","spacer","symbols","standard","output","fullforms","exponent","roundingMethod","precision","val","u","Number","isNaN","TypeError","isFinite","getBaseConfiguration","full","neg","roundingFunc","value","toPrecision","unit","handleZeroValue","calculatedE","precisionAdjusted","floor","calculateExponent","valueResult","valueExponent","rounded","p","r","pow","applyRounding","precisionResult","parseFloat","includes","computed","applyPrecisionHandling","symbolTable","resolveSymbol","localePad","minimumFractionDigits","maximumFractionDigits","undefined","toLocaleString","length","toString","replace","x","tmp","split","s","padEnd","applyNumberFormatting","suffix","decorateResult","formatted","join","formatOutput","partial","cloned","JSON","parse","stringify"],"mappings":";;;;AACO,MAAMA,EAAiB,iBAIjBC,EAAM,MACNC,EAAQ,QACRC,EAAK,KAKLC,EAAO,OAMPC,EAAQ,QAERC,EAAS,SACTC,EAAS,SAGTC,EAAW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,EACAhB,GDoPK,SAAsBmB,EAAQH,EAAGsB,EAAGN,EAAQH,GAClD,GAAIG,IAAWxC,EACd,OAAO2B,EAGR,GAAIa,IAAWvC,EACd,MAAO,CACNsD,MAAO5B,EAAO,GACdrB,OAAQqB,EAAO,GACfe,SAAUlB,EACViC,KAAMX,GAIR,IAAI+C,EAMJ,OAJCA,ED1ZmB,MCyZhBxD,EACS,GAAGV,EAAO,MAAMA,EAAO,KAEvBA,EAAOmE,KAAKzD,GAElBwD,CACR,CCtQQE,CAAapE,EAAQH,EAAGsB,EAAGN,EAAQH,EAC3C,CA4BO,SAAS2D,GAAQxF,KACvBA,GAAO,EAAKsB,IACZA,GAAM,EAAKC,KACXA,GAAO,EAAEC,MACTA,EAAQ,EAACC,OACTA,EAASC,GAAKE,UACdA,EAAYF,GAAKG,OACjBA,EF7LoB,IE6LNE,SACdA,EAAWL,GAAKM,OAChBA,EAAStC,EAAMS,SACfA,GAAW,EAAK+B,SAChBA,GAAW,EAAEC,eACbA,EAAiBvC,EAAKwC,UACtBA,EAAY,EAACT,cACbA,EAAgB,CAAA,EAAEG,QAClBA,EAAU,CAAA,EAAEG,UACZA,EAAY,IACT,IACH,MAAMwD,EAAS,CACd9D,cAAe+D,KAAKC,MAAMD,KAAKE,UAAUjE,IACzCG,QAAS4D,KAAKC,MAAMD,KAAKE,UAAU9D,IACnCG,UAAWyD,KAAKC,MAAMD,KAAKE,UAAU3D,KAGtC,OAAQZ,GACPD,EAASC,EAAK,CACbrB,OACAsB,MACAC,OACAC,QACAC,SACAE,cAAe8D,EAAO9D,cACtBC,YACAC,SACAC,QAAS2D,EAAO3D,QAChBC,WACAC,SACA7B,WACA8B,UAAWwD,EAAOxD,UAClBC,WACAC,iBACAC,aAEH,QAAAhB,cAAAoE"} diff --git a/dist/filesize.umd.js b/dist/filesize.umd.js index 571a1f6..31118d7 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.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"; @@ -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; diff --git a/dist/filesize.umd.min.js b/dist/filesize.umd.min.js index 02ba032..1659dbc 100644 --- a/dist/filesize.umd.min.js +++ b/dist/filesize.umd.min.js @@ -1,5 +1,5 @@ /*! 2026 Jason Mulligan - @version 11.0.17 + @version 11.0.18 */ -!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:N={},separator:g="",spacer:x=" ",symbols:S={},standard:O="",output:T=l,fullform:E=!1,fullforms:v=[],exponent:w=-1,roundingMethod:D=c,precision:J=0}={}){let j,$=w,k=[],G=0,K="";if("bigint"==typeof t)j=Number(t);else{if(j=Number(t),isNaN(t))throw new TypeError(e);if(!isFinite(j))throw new TypeError(e)}const{isDecimal:P,ceil:Y,actualStandard:Z}=function(t,e){return y[t]?y[t]:2===e?{isDecimal:!1,ceil:1024,actualStandard:i}:{isDecimal:!0,ceil:1e3,actualStandard:n}}(O,d),F=!0===E,z=j<0,I=Math[D];if("function"!=typeof I)throw new TypeError("Invalid rounding method");if(z&&(j=-j),0===j)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,Z,o,S,F,v,T,x);const{e:q,precision:A}=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}}(j,$,0,P,J);$=q;const C=-1===w||isNaN(w);if(T===u)return $;const{result:H,e:L}=h(j,$,P,o,Y,C);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,Y,$,B,I,C);if(k[0]=Q.value,$=Q.e,A>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],A,$,j,P,o,Y,I,B,w);k[0]=t.value,$=t.e}return K=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}(Z,o,$,P),k[1]=K,function(t,e,i,n,o,a,s,l,u,c,b,d,p){if(e&&(t[0]=-t[0]),i[t[1]]&&(t[1]=i[t[1]]),t[0]=function(t,e,i,n,o,r){let a=t;if(!0===e?a=a.toLocaleString():e.length>0?a=a.toLocaleString(e,i):n.length>0&&(a=a.toString().replace(".",n)),o&&r>0){const t=a.toString(),e=n||(t.slice(1).match(/[.,]/g)||[]).pop()||".",i=t.split(e),o=i[1]||"",s=o.length,l=r-s;a=`${i[0]}${e}${o.padEnd(s+l,"0")}`}return a}(t[0],n,o,a,s,l),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,N,g,b,B,F,v,Z,$,o),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,$,K,T,x)}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=[]}={}){const M={localeOptions:JSON.parse(JSON.stringify(m)),symbols:JSON.parse(JSON.stringify(y)),fullforms:JSON.parse(JSON.stringify(h))};return l=>B(l,{bits:t,pad:e,base:i,round:n,locale:o,localeOptions:M.localeOptions,separator:r,spacer:a,symbols:M.symbols,standard:s,output:u,fullform:f,fullforms:M.fullforms,exponent:b,roundingMethod:d,precision:p})}});//# sourceMappingURL=filesize.umd.min.js.map +!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:g="",localeOptions:M={},separator:N="",spacer:x=" ",symbols:S={},standard:O="",output:T=l,fullform:v=!1,fullforms:D=[],exponent:E=-1,roundingMethod:w=c,precision:J=0}={}){let j,F=E,$=[],k=0,G="";if("bigint"==typeof t)j=Number(t);else{if(j=Number(t),isNaN(t))throw new TypeError(e);if(!isFinite(j))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}}(O,d),Z=!0===v,z=j<0,I=Math[w];if("function"!=typeof I)throw new TypeError("Invalid rounding method");if(z&&(j=-j),0===j)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,D,T,x);const{e:q,precision:A}=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}}(j,F,0,K,J);F=q;const C=-1===E||isNaN(E);if(T===u)return F;const{result:H,e:L}=h(j,F,K,o,P,C);k=H,F=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}}(k,P,F,B,I,C);if($[0]=Q.value,F=Q.e,A>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}}($[0],A,F,j,K,o,P,I,B,E);$[0]=t.value,F=t.e}return G=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,F,K),$[1]=G,function(t,e,i,n,o,a,s,l,u,c,b,d,p){if(e&&(t[0]=-t[0]),i[t[1]]&&(t[1]=i[t[1]]),t[0]=function(t,e,i,n,o,r){let a=t;const s=o&&r>0?{minimumFractionDigits:r,maximumFractionDigits:r}:void 0;if(!0===e?a=a.toLocaleString(void 0,s):e.length>0?a=a.toLocaleString(e,{...i,...s}):n.length>0&&(a=a.toString().replace(".",n)),o&&r>0&&!0!==e&&0===e.length){const t=n||".",e=a.toString().split(t),i=e[1]||"";a=`${e[0]}${t}${i.padEnd(r,"0")}`}return a}(t[0],n,o,a,s,l),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}}($,z,S,g,M,N,b,B,Z,D,Y,F,o),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}($,F,G,T,x)}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=[]}={}){const g={localeOptions:JSON.parse(JSON.stringify(m)),symbols:JSON.parse(JSON.stringify(y)),fullforms:JSON.parse(JSON.stringify(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/dist/filesize.umd.min.js.map b/dist/filesize.umd.min.js.map index 5dab373..a0d1ff6 100644 --- a/dist/filesize.umd.min.js.map +++ b/dist/filesize.umd.min.js.map @@ -1 +1 @@ -{"version":3,"file":"filesize.umd.min.js","sources":["../src/constants.js","../src/helpers.js","../src/filesize.js"],"sourcesContent":["// Error Messages\nexport const INVALID_NUMBER = \"Invalid number\";\nexport const INVALID_ROUND = \"Invalid rounding method\";\n\n// Standard Types\nexport const IEC = \"iec\";\nexport const JEDEC = \"jedec\";\nexport const SI = \"si\";\n\n// Unit Types\nexport const BIT = \"bit\";\nexport const BITS = \"bits\";\nexport const BYTE = \"byte\";\nexport const BYTES = \"bytes\";\nexport const SI_KBIT = \"kbit\";\nexport const SI_KBYTE = \"kB\";\n\n// Output Format Types\nexport const ARRAY = \"array\";\nexport const FUNCTION = \"function\";\nexport const OBJECT = \"object\";\nexport const STRING = \"string\";\n\n// Processing Constants\nexport const EXPONENT = \"exponent\";\nexport const ROUND = \"round\";\n\n// Special Characters and Values\nexport const E = \"e\";\nexport const EMPTY = \"\";\nexport const PERIOD = \".\";\nexport const S = \"s\";\nexport const SPACE = \" \";\nexport const ZERO = \"0\";\n\n// Data Structures\nexport const STRINGS = {\n\tsymbol: {\n\t\tiec: {\n\t\t\tbits: [\"bit\", \"Kibit\", \"Mibit\", \"Gibit\", \"Tibit\", \"Pibit\", \"Eibit\", \"Zibit\", \"Yibit\"],\n\t\t\tbytes: [\"B\", \"KiB\", \"MiB\", \"GiB\", \"TiB\", \"PiB\", \"EiB\", \"ZiB\", \"YiB\"],\n\t\t},\n\t\tjedec: {\n\t\t\tbits: [\"bit\", \"Kbit\", \"Mbit\", \"Gbit\", \"Tbit\", \"Pbit\", \"Ebit\", \"Zbit\", \"Ybit\"],\n\t\t\tbytes: [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"],\n\t\t},\n\t},\n\tfullform: {\n\t\tiec: [\"\", \"kibi\", \"mebi\", \"gibi\", \"tebi\", \"pebi\", \"exbi\", \"zebi\", \"yobi\"],\n\t\tjedec: [\"\", \"kilo\", \"mega\", \"giga\", \"tera\", \"peta\", \"exa\", \"zetta\", \"yotta\"],\n\t},\n};\n\n// Pre-computed lookup tables for performance optimization\nexport const BINARY_POWERS = [\n\t1, // 2^0\n\t1024, // 2^10\n\t1048576, // 2^20\n\t1073741824, // 2^30\n\t1099511627776, // 2^40\n\t1125899906842624, // 2^50\n\t1152921504606846976, // 2^60\n\t1180591620717411303424, // 2^70\n\t1208925819614629174706176, // 2^80\n];\n\nexport const DECIMAL_POWERS = [\n\t1, // 10^0\n\t1000, // 10^3\n\t1000000, // 10^6\n\t1000000000, // 10^9\n\t1000000000000, // 10^12\n\t1000000000000000, // 10^15\n\t1000000000000000000, // 10^18\n\t1000000000000000000000, // 10^21\n\t1000000000000000000000000, // 10^24\n];\n\n// Pre-computed log values for faster exponent calculation\nexport const LOG_2_1024 = Math.log(1024);\nexport const LOG_10_1000 = Math.log(1000);\n","import {\n\tARRAY,\n\tBINARY_POWERS,\n\tBIT,\n\tBITS,\n\tBYTE,\n\tBYTES,\n\tDECIMAL_POWERS,\n\tE,\n\tEMPTY,\n\tEXPONENT,\n\tIEC,\n\tJEDEC,\n\tLOG_10_1000,\n\tLOG_2_1024,\n\tOBJECT,\n\tPERIOD,\n\tS,\n\tSI,\n\tSI_KBIT,\n\tSI_KBYTE,\n\tSPACE,\n\tSTRINGS,\n\tZERO,\n} from \"./constants.js\";\n\n// Cached configuration lookup for better performance\nconst STANDARD_CONFIGS = {\n\t[SI]: { isDecimal: true, ceil: 1000, actualStandard: JEDEC },\n\t[IEC]: { isDecimal: false, ceil: 1024, actualStandard: IEC },\n\t[JEDEC]: { isDecimal: false, ceil: 1024, actualStandard: JEDEC },\n};\n\n/**\n * Optimized base configuration lookup\n * @param {string} standard - Standard type\n * @param {number} base - Base number\n * @returns {Object} Configuration object\n */\nexport function getBaseConfiguration(standard, base) {\n\t// Use cached lookup table for better performance\n\tif (STANDARD_CONFIGS[standard]) {\n\t\treturn STANDARD_CONFIGS[standard];\n\t}\n\n\t// Base override\n\tif (base === 2) {\n\t\treturn { isDecimal: false, ceil: 1024, actualStandard: IEC };\n\t}\n\n\t// Default\n\treturn { isDecimal: true, ceil: 1000, actualStandard: JEDEC };\n}\n\n/**\n * Optimized zero value handling\n * @param {number} precision - Precision value\n * @param {string} actualStandard - Standard to use\n * @param {boolean} bits - Whether to use bits\n * @param {Object} symbols - Custom symbols\n * @param {boolean} full - Whether to use full form\n * @param {Array} fullforms - Custom full forms\n * @param {string} output - Output format\n * @param {string} spacer - Spacer character\n * @param {string} [symbol] - Symbol to use (defaults based on bits/standard)\n * @returns {string|Array|Object|number} Formatted result\n */\nexport function handleZeroValue(\n\tprecision,\n\tactualStandard,\n\tbits,\n\tsymbols,\n\tfull,\n\tfullforms,\n\toutput,\n\tspacer,\n\tsymbol,\n) {\n\tlet value;\n\tif (precision > 0) {\n\t\tvalue = (0).toPrecision(precision);\n\t} else {\n\t\tvalue = 0;\n\t}\n\n\tif (output === EXPONENT) {\n\t\treturn 0;\n\t}\n\n\t// Set default symbol if not provided\n\tif (!symbol) {\n\t\tsymbol = bits\n\t\t\t? STRINGS.symbol[actualStandard].bits[0]\n\t\t\t: STRINGS.symbol[actualStandard].bytes[0];\n\t}\n\n\t// Apply symbol customization\n\tif (symbols[symbol]) {\n\t\tsymbol = symbols[symbol];\n\t}\n\n\t// Apply full form\n\tif (full) {\n\t\tif (fullforms[0]) {\n\t\t\tsymbol = fullforms[0];\n\t\t} else {\n\t\t\tsymbol = STRINGS.fullform[actualStandard][0];\n\t\t\tif (bits) {\n\t\t\t\tsymbol += BIT;\n\t\t\t} else {\n\t\t\t\tsymbol += BYTE;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return in requested format\n\tif (output === ARRAY) {\n\t\treturn [value, symbol];\n\t}\n\n\tif (output === OBJECT) {\n\t\treturn { value, symbol, exponent: 0, unit: symbol };\n\t}\n\n\treturn value + spacer + symbol;\n}\n\n/**\n * Optimized value calculation with bits handling\n * @param {number} num - Input number\n * @param {number} e - Exponent\n * @param {boolean} isDecimal - Whether to use decimal powers\n * @param {boolean} bits - Whether to calculate bits\n * @param {number} ceil - Ceiling value for auto-increment\n * @param {boolean} autoExponent - Whether exponent is auto (-1 or NaN)\n * @returns {Object} Object with result and e properties\n */\nexport function calculateOptimizedValue(num, e, isDecimal, bits, ceil, autoExponent = true) {\n\tlet d;\n\tif (isDecimal) {\n\t\td = DECIMAL_POWERS[e];\n\t} else {\n\t\td = BINARY_POWERS[e];\n\t}\n\tlet result = num / d;\n\n\tif (bits) {\n\t\tresult *= 8;\n\t\t// Handle auto-increment for bits (only when exponent is auto)\n\t\tif (autoExponent && result >= ceil && e < 8) {\n\t\t\tresult /= ceil;\n\t\t\te++;\n\t\t}\n\t}\n\n\treturn { result, e };\n}\n\n/**\n * Optimized precision handling with scientific notation correction\n * @param {number} value - Current value\n * @param {number} precision - Precision to apply\n * @param {number} e - Current exponent\n * @param {number} num - Original number\n * @param {boolean} isDecimal - Whether using decimal base\n * @param {boolean} bits - Whether calculating bits\n * @param {number} ceil - Ceiling value\n * @param {Function} roundingFunc - Rounding function\n * @param {number} round - Round value\n * @param {number} exponent - Forced exponent (-1 for auto)\n * @returns {Object} Object with value and e properties\n */\nexport function applyPrecisionHandling(\n\tvalue,\n\tprecision,\n\te,\n\tnum,\n\tisDecimal,\n\tbits,\n\tceil,\n\troundingFunc,\n\tround,\n\texponent,\n) {\n\tif (typeof value === \"string\") {\n\t\tvalue = parseFloat(value);\n\t}\n\n\tlet result = value.toPrecision(precision);\n\n\tconst autoExponent = exponent === -1 || isNaN(exponent);\n\n\t// Handle scientific notation by recalculating with incremented exponent\n\tif (result.includes(E) && e < 8 && autoExponent) {\n\t\te++;\n\t\tconst { result: valueResult } = calculateOptimizedValue(num, e, isDecimal, bits, ceil);\n\t\tlet p;\n\t\tif (round > 0) {\n\t\t\tp = Math.pow(10, round);\n\t\t} else {\n\t\t\tp = 1;\n\t\t}\n\t\tlet computed;\n\t\tif (p === 1) {\n\t\t\tcomputed = roundingFunc(valueResult);\n\t\t} else {\n\t\t\tcomputed = roundingFunc(valueResult * p) / p;\n\t\t}\n\t\tresult = computed.toPrecision(precision);\n\t}\n\n\treturn { value: result, e };\n}\n\n/**\n * Optimized number formatting with locale, separator, and padding\n * @param {number|string} value - Value to format\n * @param {string|boolean} locale - Locale setting\n * @param {Object} localeOptions - Locale options\n * @param {string} separator - Custom separator\n * @param {boolean} pad - Whether to pad\n * @param {number} round - Round value\n * @returns {string|number} Formatted value\n */\nexport function applyNumberFormatting(value, locale, localeOptions, separator, pad, round) {\n\tlet result = value;\n\n\t// Apply locale formatting\n\tif (locale === true) {\n\t\tresult = result.toLocaleString();\n\t} else if (locale.length > 0) {\n\t\tresult = result.toLocaleString(locale, localeOptions);\n\t} else if (separator.length > 0) {\n\t\tresult = result.toString().replace(PERIOD, separator);\n\t}\n\n\t// Apply padding\n\tif (pad && round > 0) {\n\t\tconst resultStr = result.toString();\n\t\tconst x = separator || (resultStr.slice(1).match(/[.,]/g) || []).pop() || PERIOD;\n\t\tconst tmp = resultStr.split(x);\n\t\tconst s = tmp[1] || EMPTY;\n\n\t\tconst l = s.length;\n\t\tconst n = round - l;\n\n\t\tresult = `${tmp[0]}${x}${s.padEnd(l + n, ZERO)}`;\n\t}\n\n\treturn result;\n}\n\n/**\n * Calculates exponent from the input value using pre-computed log values and clamps to supported range\n * Also adjusts precision when exponent exceeds the lookup table bounds\n * @param {number} num - Input file size in bytes\n * @param {number} e - Current exponent value\n * @param {number} exponent - Original user-provided exponent option (-1 for auto)\n * @param {boolean} isDecimal - Whether to use decimal (SI) base\n * @param {number} precision - Current precision value (modified when e > 8)\n * @returns {Object} Object with computed e value and possibly adjusted precision\n */\nexport function calculateExponent(num, e, exponent, isDecimal, precision) {\n\tif (e === -1 || isNaN(e)) {\n\t\tif (isDecimal) {\n\t\t\te = Math.floor(Math.log(num) / LOG_10_1000);\n\t\t} else {\n\t\t\te = Math.floor(Math.log(num) / LOG_2_1024);\n\t\t}\n\t\tif (e < 0) {\n\t\t\te = 0;\n\t\t}\n\t}\n\n\tif (e > 8) {\n\t\tif (precision > 0) {\n\t\t\tprecision += 8 - e;\n\t\t}\n\t\treturn { e: 8, precision };\n\t}\n\n\treturn { e, precision };\n}\n\n/**\n * Applies rounding to the raw calculated value and handles auto-increment ceiling\n * @param {number} val - Raw value before rounding\n * @param {number} ceil - Ceiling threshold (1000 for SI, 1024 for IEC)\n * @param {number} e - Current exponent value\n * @param {number} round - Number of decimal places\n * @param {Function} roundingFunc - Rounding method (Math.round, Math.floor, Math.ceil)\n * @param {boolean} autoExponent - Whether exponent is auto-calculated (-1 or NaN)\n * @returns {Object} Object with rounded value and possibly incremented exponent\n */\nexport function applyRounding(val, ceil, e, round, roundingFunc, autoExponent) {\n\tlet p;\n\tif (e > 0 && round > 0) {\n\t\tp = Math.pow(10, round);\n\t} else {\n\t\tp = 1;\n\t}\n\tlet r;\n\tif (p === 1) {\n\t\tr = roundingFunc(val);\n\t} else {\n\t\tr = roundingFunc(val * p) / p;\n\t}\n\n\tif (r === ceil && e < 8 && autoExponent) {\n\t\tr = 1;\n\t\te++;\n\t}\n\n\treturn { value: r, e };\n}\n\n/**\n * Resolves the unit symbol for the given standard, bits mode, and exponent\n * Handles SI standard special case where exponent 1 always uses \"kB\" or \"kbit\"\n * @param {string} actualStandard - The resolved standard (iec, jedec)\n * @param {boolean} bits - Whether formatting bit values\n * @param {number} e - Current exponent index\n * @param {boolean} isDecimal - Whether using decimal (SI) base\n * @returns {string} The resolved unit symbol string\n */\nexport function resolveSymbol(actualStandard, bits, e, isDecimal) {\n\tconst symbolTable = STRINGS.symbol[actualStandard][bits ? BITS : BYTES];\n\tlet result;\n\tif (isDecimal && e === 1) {\n\t\tif (bits) {\n\t\t\tresult = SI_KBIT;\n\t\t} else {\n\t\t\tresult = SI_KBYTE;\n\t\t}\n\t} else {\n\t\tresult = symbolTable[e];\n\t}\n\treturn result;\n}\n\n/**\n * Decorates the result: applies negation, custom symbols, number formatting, and full form names\n * Mutates the result array in-place for both value (index 0) and symbol (index 1)\n * @param {Array} result - Result array with numeric value at [0] and string symbol at [1]\n * @param {boolean} neg - Whether the original input was negative\n * @param {Object} symbols - Custom symbol override map\n * @param {string|boolean} locale - Locale string for formatting\n * @param {Object} localeOptions - Additional locale formatting options\n * @param {string} separator - Custom decimal separator\n * @param {boolean} pad - Whether zero-pad decimals\n * @param {number} round - Target decimal count for padding\n * @param {boolean} full - Whether to use full unit names\n * @param {Array} fullforms - Custom full unit name overrides\n * @param {string} actualStandard - Unit standard for full form lookup\n * @param {number} e - Current exponent index\n * @param {boolean} bits - Whether formatting bit values\n * @returns {void} Mutates result array in place\n */\nexport function decorateResult(\n\tresult,\n\tneg,\n\tsymbols,\n\tlocale,\n\tlocaleOptions,\n\tseparator,\n\tpad,\n\tround,\n\tfull,\n\tfullforms,\n\tactualStandard,\n\te,\n\tbits,\n) {\n\tif (neg) {\n\t\tresult[0] = -result[0];\n\t}\n\n\tif (symbols[result[1]]) {\n\t\tresult[1] = symbols[result[1]];\n\t}\n\n\tresult[0] = applyNumberFormatting(result[0], locale, localeOptions, separator, pad, round);\n\n\tif (full) {\n\t\tlet unit;\n\t\tif (bits) {\n\t\t\tunit = BIT;\n\t\t} else {\n\t\t\tunit = BYTE;\n\t\t}\n\t\tlet val;\n\t\tif (typeof result[0] === \"string\") {\n\t\t\tval = parseFloat(result[0]);\n\t\t} else {\n\t\t\tval = result[0];\n\t\t}\n\t\t// Determine singular/plural suffix\n\t\tlet suffix;\n\t\tif (val === 1) {\n\t\t\tsuffix = EMPTY;\n\t\t} else {\n\t\t\tsuffix = S;\n\t\t}\n\t\t// Determine symbol — custom fullforms are the complete name, defaults get unit+suffix\n\t\tif (fullforms[e]) {\n\t\t\tresult[1] = fullforms[e];\n\t\t} else {\n\t\t\tresult[1] = STRINGS.fullform[actualStandard][e] + unit + suffix;\n\t\t}\n\t}\n}\n\n/**\n * Formats the computed result array into the requested output type\n * @param {Array} result - Result array with formatted value at [0] and symbol at [1]\n * @param {number} e - Current exponent\n * @param {string} u - Original resolved symbol (before custom override)\n * @param {string} output - Output type (ARRAY, OBJECT, STRING)\n * @param {string} spacer - String separator between value and unit\n * @returns {string|Array|Object|number} Formatted result in requested type\n */\nexport function formatOutput(result, e, u, output, spacer) {\n\tif (output === ARRAY) {\n\t\treturn result;\n\t}\n\n\tif (output === OBJECT) {\n\t\treturn {\n\t\t\tvalue: result[0],\n\t\t\tsymbol: result[1],\n\t\t\texponent: e,\n\t\t\tunit: u,\n\t\t};\n\t}\n\n\tlet formatted;\n\tif (spacer === SPACE) {\n\t\tformatted = `${result[0]} ${result[1]}`;\n\t} else {\n\t\tformatted = result.join(spacer);\n\t}\n\treturn formatted;\n}\n","import {\n\tEMPTY,\n\tEXPONENT,\n\tFUNCTION,\n\tINVALID_NUMBER,\n\tINVALID_ROUND,\n\tROUND,\n\tSPACE,\n\tSTRING,\n} from \"./constants.js\";\nimport {\n\tapplyPrecisionHandling,\n\tapplyRounding,\n\tcalculateExponent,\n\tcalculateOptimizedValue,\n\tdecorateResult,\n\tformatOutput,\n\tgetBaseConfiguration,\n\thandleZeroValue,\n\tresolveSymbol,\n} from \"./helpers.js\";\n\n/**\n * Converts a file size in bytes to a human-readable string with appropriate units\n * @param {number|string|bigint} arg - The file size in bytes to convert\n * @param {Object} [options={}] - Configuration options for formatting\n * @param {boolean} [options.bits=false] - If true, calculates bits instead of bytes\n * @param {boolean} [options.pad=false] - If true, pads decimal places to match round parameter\n * @param {number} [options.base=-1] - Number base (2 for binary, 10 for decimal, -1 for auto)\n * @param {number} [options.round=2] - Number of decimal places to round to\n * @param {string|boolean} [options.locale=\"\"] - Locale for number formatting, true for system locale\n * @param {Object} [options.localeOptions={}] - Additional options for locale formatting\n * @param {string} [options.separator=\"\"] - Custom decimal separator\n * @param {string} [options.spacer=\" \"] - String to separate value and unit\n * @param {Object} [options.symbols={}] - Custom unit symbols\n * @param {string} [options.standard=\"\"] - Unit standard to use (SI, IEC, JEDEC)\n * @param {string} [options.output=\"string\"] - Output format: \"string\", \"array\", \"object\", or \"exponent\"\n * @param {boolean} [options.fullform=false] - If true, uses full unit names instead of abbreviations\n * @param {Array} [options.fullforms=[]] - Custom full unit names\n * @param {number} [options.exponent=-1] - Force specific exponent (-1 for auto)\n * @param {string} [options.roundingMethod=\"round\"] - Math rounding method to use\n * @param {number} [options.precision=0] - Number of significant digits (0 for auto)\n * @returns {string|Array|Object|number} Formatted file size based on output option\n * @throws {TypeError} When arg is not a valid number or roundingMethod is invalid\n * @example\n * filesize(1024) // \"1.02 kB\"\n * filesize(1024, {bits: true}) // \"8.19 kbit\"\n * filesize(1024, {output: \"object\"}) // {value: 1.02, symbol: \"kB\", exponent: 1, unit: \"kB\"}\n */\nexport function filesize(\n\targ,\n\t{\n\t\tbits = false,\n\t\tpad = false,\n\t\tbase = -1,\n\t\tround = 2,\n\t\tlocale = EMPTY,\n\t\tlocaleOptions = {},\n\t\tseparator = EMPTY,\n\t\tspacer = SPACE,\n\t\tsymbols = {},\n\t\tstandard = EMPTY,\n\t\toutput = STRING,\n\t\tfullform = false,\n\t\tfullforms = [],\n\t\texponent = -1,\n\t\troundingMethod = ROUND,\n\t\tprecision = 0,\n\t} = {},\n) {\n\tlet e = exponent,\n\t\tnum,\n\t\tresult = [],\n\t\tval = 0,\n\t\tu = EMPTY;\n\n\tif (typeof arg === \"bigint\") {\n\t\tnum = Number(arg);\n\t} else {\n\t\tnum = Number(arg);\n\n\t\tif (isNaN(arg)) {\n\t\t\tthrow new TypeError(INVALID_NUMBER);\n\t\t}\n\n\t\tif (!isFinite(num)) {\n\t\t\tthrow new TypeError(INVALID_NUMBER);\n\t\t}\n\t}\n\n\tconst { isDecimal, ceil, actualStandard } = getBaseConfiguration(standard, base);\n\n\tconst full = fullform === true,\n\t\tneg = num < 0,\n\t\troundingFunc = Math[roundingMethod];\n\n\tif (typeof roundingFunc !== FUNCTION) {\n\t\tthrow new TypeError(INVALID_ROUND);\n\t}\n\n\tif (neg) {\n\t\tnum = -num;\n\t}\n\n\tif (num === 0) {\n\t\treturn handleZeroValue(\n\t\t\tprecision,\n\t\t\tactualStandard,\n\t\t\tbits,\n\t\t\tsymbols,\n\t\t\tfull,\n\t\t\tfullforms,\n\t\t\toutput,\n\t\t\tspacer,\n\t\t);\n\t}\n\n\t// Exponent calculation + clamp + precision adjustment\n\tconst { e: calculatedE, precision: precisionAdjusted } = calculateExponent(\n\t\tnum,\n\t\te,\n\t\texponent,\n\t\tisDecimal,\n\t\tprecision,\n\t);\n\te = calculatedE;\n\tconst autoExponent = exponent === -1 || isNaN(exponent);\n\n\tif (output === EXPONENT) {\n\t\treturn e;\n\t}\n\n\tconst { result: valueResult, e: valueExponent } = calculateOptimizedValue(\n\t\tnum,\n\t\te,\n\t\tisDecimal,\n\t\tbits,\n\t\tceil,\n\t\tautoExponent,\n\t);\n\tval = valueResult;\n\te = valueExponent;\n\n\t// Rounding + auto-increment ceiling\n\tconst rounded = applyRounding(val, ceil, e, round, roundingFunc, autoExponent);\n\tresult[0] = rounded.value;\n\te = rounded.e;\n\n\t// Precision handling\n\tif (precisionAdjusted > 0) {\n\t\tconst precisionResult = applyPrecisionHandling(\n\t\t\tresult[0],\n\t\t\tprecisionAdjusted,\n\t\t\te,\n\t\t\tnum,\n\t\t\tisDecimal,\n\t\t\tbits,\n\t\t\tceil,\n\t\t\troundingFunc,\n\t\t\tround,\n\t\t\texponent,\n\t\t);\n\t\tresult[0] = precisionResult.value;\n\t\te = precisionResult.e;\n\t}\n\n\tu = resolveSymbol(actualStandard, bits, e, isDecimal);\n\tresult[1] = u;\n\n\tdecorateResult(\n\t\tresult,\n\t\tneg,\n\t\tsymbols,\n\t\tlocale,\n\t\tlocaleOptions,\n\t\tseparator,\n\t\tpad,\n\t\tround,\n\t\tfull,\n\t\tfullforms,\n\t\tactualStandard,\n\t\te,\n\t\tbits,\n\t);\n\n\treturn formatOutput(result, e, u, output, spacer);\n}\n\n/**\n * Creates a partially applied version of filesize with preset options\n * @param {Object} [options={}] - Configuration options (same as filesize)\n * @param {boolean} [options.bits=false] - If true, calculates bits instead of bytes\n * @param {boolean} [options.pad=false] - If true, pads decimal places to match round parameter\n * @param {number} [options.base=-1] - Number base (2 for binary, 10 for decimal, -1 for auto)\n * @param {number} [options.round=2] - Number of decimal places to round to\n * @param {string|boolean} [options.locale=\"\"] - Locale for number formatting, true for system locale\n * @param {Object} [options.localeOptions={}] - Additional options for locale formatting\n * @param {string} [options.separator=\"\"] - Custom decimal separator\n * @param {string} [options.spacer=\" \"] - String to separate value and unit\n * @param {Object} [options.symbols={}] - Custom unit symbols\n * @param {string} [options.standard=\"\"] - Unit standard to use (SI, IEC, JEDEC)\n * @param {string} [options.output=\"string\"] - Output format: \"string\", \"array\", \"object\", or \"exponent\"\n * @param {boolean} [options.fullform=false] - If true, uses full unit names instead of abbreviations\n * @param {Array} [options.fullforms=[]] - Custom full unit names\n * @param {number} [options.exponent=-1] - Force specific exponent (-1 for auto)\n * @param {string} [options.roundingMethod=\"round\"] - Math rounding method to use\n * @param {number} [options.precision=0] - Number of significant digits (0 for auto)\n * @returns {Function} A function that takes a file size and returns formatted output\n * @example\n * const formatBytes = partial({round: 1, standard: \"iec\"});\n * formatBytes(1024) // \"1 KiB\"\n * formatBytes(2048) // \"2 KiB\"\n * formatBytes(1536) // \"1.5 KiB\"\n */\nexport function partial({\n\tbits = false,\n\tpad = false,\n\tbase = -1,\n\tround = 2,\n\tlocale = EMPTY,\n\tseparator = EMPTY,\n\tspacer = SPACE,\n\tstandard = EMPTY,\n\toutput = STRING,\n\tfullform = false,\n\texponent = -1,\n\troundingMethod = ROUND,\n\tprecision = 0,\n\tlocaleOptions = {},\n\tsymbols = {},\n\tfullforms = [],\n} = {}) {\n\tconst cloned = {\n\t\tlocaleOptions: JSON.parse(JSON.stringify(localeOptions)),\n\t\tsymbols: JSON.parse(JSON.stringify(symbols)),\n\t\tfullforms: JSON.parse(JSON.stringify(fullforms)),\n\t};\n\n\treturn (arg) =>\n\t\tfilesize(arg, {\n\t\t\tbits,\n\t\t\tpad,\n\t\t\tbase,\n\t\t\tround,\n\t\t\tlocale,\n\t\t\tlocaleOptions: cloned.localeOptions,\n\t\t\tseparator,\n\t\t\tspacer,\n\t\t\tsymbols: cloned.symbols,\n\t\t\tstandard,\n\t\t\toutput,\n\t\t\tfullform,\n\t\t\tfullforms: cloned.fullforms,\n\t\t\texponent,\n\t\t\troundingMethod,\n\t\t\tprecision,\n\t\t});\n}\n"],"names":["g","f","exports","module","define","amd","globalThis","self","filesize","this","INVALID_NUMBER","IEC","JEDEC","SI","BYTE","ARRAY","OBJECT","STRING","EXPONENT","ROUND","STRINGS","symbol","iec","bits","bytes","jedec","fullform","BINARY_POWERS","DECIMAL_POWERS","LOG_2_1024","Math","log","LOG_10_1000","STANDARD_CONFIGS","isDecimal","ceil","actualStandard","calculateOptimizedValue","num","e","autoExponent","d","result","arg","pad","base","round","locale","EMPTY","localeOptions","separator","spacer","symbols","standard","output","fullforms","exponent","roundingMethod","precision","val","u","Number","isNaN","TypeError","isFinite","getBaseConfiguration","full","neg","roundingFunc","value","toPrecision","unit","handleZeroValue","calculatedE","precisionAdjusted","floor","calculateExponent","valueResult","valueExponent","rounded","p","r","pow","applyRounding","precisionResult","parseFloat","includes","computed","applyPrecisionHandling","symbolTable","resolveSymbol","toLocaleString","length","toString","replace","resultStr","x","slice","match","pop","tmp","split","s","l","n","padEnd","applyNumberFormatting","suffix","decorateResult","formatted","join","formatOutput","partial","cloned","JSON","parse","stringify"],"mappings":";;;;CAAA,SAAAA,EAAAC,GAAA,iBAAAC,SAAA,oBAAAC,OAAAF,EAAAC,SAAA,mBAAAE,QAAAA,OAAAC,IAAAD,OAAA,CAAA,WAAAH,GAAAA,GAAAD,EAAA,oBAAAM,WAAAA,WAAAN,GAAAO,MAAAC,SAAA,CAAA,EAAA,CAAA,CAAAC,KAAA,SAAAP,GAAA,aACO,MAAMQ,EAAiB,iBAIjBC,EAAM,MACNC,EAAQ,QACRC,EAAK,KAKLC,EAAO,OAMPC,EAAQ,QAERC,EAAS,SACTC,EAAS,SAGTC,EAAW,WACXC,EAAQ,QAWRC,EAAU,CACtBC,OAAQ,CACPC,IAAK,CACJC,KAAM,CAAC,MAAO,QAAS,QAAS,QAAS,QAAS,QAAS,QAAS,QAAS,SAC7EC,MAAO,CAAC,IAAK,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,QAE/DC,MAAO,CACNF,KAAM,CAAC,MAAO,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,QACtEC,MAAO,CAAC,IAAK,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,QAGzDE,SAAU,CACTJ,IAAK,CAAC,GAAI,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,QAClEG,MAAO,CAAC,GAAI,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,MAAO,QAAS,WAKzDE,EAAgB,CAC5B,EACA,KACA,QACA,WACA,cACA,gBACA,mBACA,oBACA,qBAGYC,EAAiB,CAC7B,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EC,eACbA,EAAiBtC,EAAKuC,UACtBA,EAAY,EAACT,cACbA,EAAgB,CAAA,EAAEG,QAClBA,EAAU,CAAA,EAAEG,UACZA,EAAY,IACT,IACH,MAAM0D,EAAS,CACdhE,cAAeiE,KAAKC,MAAMD,KAAKE,UAAUnE,IACzCG,QAAS8D,KAAKC,MAAMD,KAAKE,UAAUhE,IACnCG,UAAW2D,KAAKC,MAAMD,KAAKE,UAAU7D,KAGtC,OAAQZ,GACPnC,EAASmC,EAAK,CACbpB,OACAqB,MACAC,OACAC,QACAC,SACAE,cAAegE,EAAOhE,cACtBC,YACAC,SACAC,QAAS6D,EAAO7D,QAChBC,WACAC,SACA5B,WACA6B,UAAW0D,EAAO1D,UAClBC,WACAC,iBACAC,aAEH,CAAA"} +{"version":3,"file":"filesize.umd.min.js","sources":["../src/constants.js","../src/helpers.js","../src/filesize.js"],"sourcesContent":["// Error Messages\nexport const INVALID_NUMBER = \"Invalid number\";\nexport const INVALID_ROUND = \"Invalid rounding method\";\n\n// Standard Types\nexport const IEC = \"iec\";\nexport const JEDEC = \"jedec\";\nexport const SI = \"si\";\n\n// Unit Types\nexport const BIT = \"bit\";\nexport const BITS = \"bits\";\nexport const BYTE = \"byte\";\nexport const BYTES = \"bytes\";\nexport const SI_KBIT = \"kbit\";\nexport const SI_KBYTE = \"kB\";\n\n// Output Format Types\nexport const ARRAY = \"array\";\nexport const FUNCTION = \"function\";\nexport const OBJECT = \"object\";\nexport const STRING = \"string\";\n\n// Processing Constants\nexport const EXPONENT = \"exponent\";\nexport const ROUND = \"round\";\n\n// Special Characters and Values\nexport const E = \"e\";\nexport const EMPTY = \"\";\nexport const PERIOD = \".\";\nexport const S = \"s\";\nexport const SPACE = \" \";\nexport const ZERO = \"0\";\n\n// Data Structures\nexport const STRINGS = {\n\tsymbol: {\n\t\tiec: {\n\t\t\tbits: [\"bit\", \"Kibit\", \"Mibit\", \"Gibit\", \"Tibit\", \"Pibit\", \"Eibit\", \"Zibit\", \"Yibit\"],\n\t\t\tbytes: [\"B\", \"KiB\", \"MiB\", \"GiB\", \"TiB\", \"PiB\", \"EiB\", \"ZiB\", \"YiB\"],\n\t\t},\n\t\tjedec: {\n\t\t\tbits: [\"bit\", \"Kbit\", \"Mbit\", \"Gbit\", \"Tbit\", \"Pbit\", \"Ebit\", \"Zbit\", \"Ybit\"],\n\t\t\tbytes: [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"],\n\t\t},\n\t},\n\tfullform: {\n\t\tiec: [\"\", \"kibi\", \"mebi\", \"gibi\", \"tebi\", \"pebi\", \"exbi\", \"zebi\", \"yobi\"],\n\t\tjedec: [\"\", \"kilo\", \"mega\", \"giga\", \"tera\", \"peta\", \"exa\", \"zetta\", \"yotta\"],\n\t},\n};\n\n// Pre-computed lookup tables for performance optimization\nexport const BINARY_POWERS = [\n\t1, // 2^0\n\t1024, // 2^10\n\t1048576, // 2^20\n\t1073741824, // 2^30\n\t1099511627776, // 2^40\n\t1125899906842624, // 2^50\n\t1152921504606846976, // 2^60\n\t1180591620717411303424, // 2^70\n\t1208925819614629174706176, // 2^80\n];\n\nexport const DECIMAL_POWERS = [\n\t1, // 10^0\n\t1000, // 10^3\n\t1000000, // 10^6\n\t1000000000, // 10^9\n\t1000000000000, // 10^12\n\t1000000000000000, // 10^15\n\t1000000000000000000, // 10^18\n\t1000000000000000000000, // 10^21\n\t1000000000000000000000000, // 10^24\n];\n\n// Pre-computed log values for faster exponent calculation\nexport const LOG_2_1024 = Math.log(1024);\nexport const LOG_10_1000 = Math.log(1000);\n","import {\n\tARRAY,\n\tBINARY_POWERS,\n\tBIT,\n\tBITS,\n\tBYTE,\n\tBYTES,\n\tDECIMAL_POWERS,\n\tE,\n\tEMPTY,\n\tEXPONENT,\n\tIEC,\n\tJEDEC,\n\tLOG_10_1000,\n\tLOG_2_1024,\n\tOBJECT,\n\tPERIOD,\n\tS,\n\tSI,\n\tSI_KBIT,\n\tSI_KBYTE,\n\tSPACE,\n\tSTRINGS,\n\tZERO,\n} from \"./constants.js\";\n\n// Cached configuration lookup for better performance\nconst STANDARD_CONFIGS = {\n\t[SI]: { isDecimal: true, ceil: 1000, actualStandard: JEDEC },\n\t[IEC]: { isDecimal: false, ceil: 1024, actualStandard: IEC },\n\t[JEDEC]: { isDecimal: false, ceil: 1024, actualStandard: JEDEC },\n};\n\n/**\n * Optimized base configuration lookup\n * @param {string} standard - Standard type\n * @param {number} base - Base number\n * @returns {Object} Configuration object\n */\nexport function getBaseConfiguration(standard, base) {\n\t// Use cached lookup table for better performance\n\tif (STANDARD_CONFIGS[standard]) {\n\t\treturn STANDARD_CONFIGS[standard];\n\t}\n\n\t// Base override\n\tif (base === 2) {\n\t\treturn { isDecimal: false, ceil: 1024, actualStandard: IEC };\n\t}\n\n\t// Default\n\treturn { isDecimal: true, ceil: 1000, actualStandard: JEDEC };\n}\n\n/**\n * Optimized zero value handling\n * @param {number} precision - Precision value\n * @param {string} actualStandard - Standard to use\n * @param {boolean} bits - Whether to use bits\n * @param {Object} symbols - Custom symbols\n * @param {boolean} full - Whether to use full form\n * @param {Array} fullforms - Custom full forms\n * @param {string} output - Output format\n * @param {string} spacer - Spacer character\n * @param {string} [symbol] - Symbol to use (defaults based on bits/standard)\n * @returns {string|Array|Object|number} Formatted result\n */\nexport function handleZeroValue(\n\tprecision,\n\tactualStandard,\n\tbits,\n\tsymbols,\n\tfull,\n\tfullforms,\n\toutput,\n\tspacer,\n\tsymbol,\n) {\n\tlet value;\n\tif (precision > 0) {\n\t\tvalue = (0).toPrecision(precision);\n\t} else {\n\t\tvalue = 0;\n\t}\n\n\tif (output === EXPONENT) {\n\t\treturn 0;\n\t}\n\n\t// Set default symbol if not provided\n\tif (!symbol) {\n\t\tsymbol = bits\n\t\t\t? STRINGS.symbol[actualStandard].bits[0]\n\t\t\t: STRINGS.symbol[actualStandard].bytes[0];\n\t}\n\n\t// Apply symbol customization\n\tif (symbols[symbol]) {\n\t\tsymbol = symbols[symbol];\n\t}\n\n\t// Apply full form\n\tif (full) {\n\t\tif (fullforms[0]) {\n\t\t\tsymbol = fullforms[0];\n\t\t} else {\n\t\t\tsymbol = STRINGS.fullform[actualStandard][0];\n\t\t\tif (bits) {\n\t\t\t\tsymbol += BIT;\n\t\t\t} else {\n\t\t\t\tsymbol += BYTE;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return in requested format\n\tif (output === ARRAY) {\n\t\treturn [value, symbol];\n\t}\n\n\tif (output === OBJECT) {\n\t\treturn { value, symbol, exponent: 0, unit: symbol };\n\t}\n\n\treturn value + spacer + symbol;\n}\n\n/**\n * Optimized value calculation with bits handling\n * @param {number} num - Input number\n * @param {number} e - Exponent\n * @param {boolean} isDecimal - Whether to use decimal powers\n * @param {boolean} bits - Whether to calculate bits\n * @param {number} ceil - Ceiling value for auto-increment\n * @param {boolean} autoExponent - Whether exponent is auto (-1 or NaN)\n * @returns {Object} Object with result and e properties\n */\nexport function calculateOptimizedValue(num, e, isDecimal, bits, ceil, autoExponent = true) {\n\tlet d;\n\tif (isDecimal) {\n\t\td = DECIMAL_POWERS[e];\n\t} else {\n\t\td = BINARY_POWERS[e];\n\t}\n\tlet result = num / d;\n\n\tif (bits) {\n\t\tresult *= 8;\n\t\t// Handle auto-increment for bits (only when exponent is auto)\n\t\tif (autoExponent && result >= ceil && e < 8) {\n\t\t\tresult /= ceil;\n\t\t\te++;\n\t\t}\n\t}\n\n\treturn { result, e };\n}\n\n/**\n * Optimized precision handling with scientific notation correction\n * @param {number} value - Current value\n * @param {number} precision - Precision to apply\n * @param {number} e - Current exponent\n * @param {number} num - Original number\n * @param {boolean} isDecimal - Whether using decimal base\n * @param {boolean} bits - Whether calculating bits\n * @param {number} ceil - Ceiling value\n * @param {Function} roundingFunc - Rounding function\n * @param {number} round - Round value\n * @param {number} exponent - Forced exponent (-1 for auto)\n * @returns {Object} Object with value and e properties\n */\nexport function applyPrecisionHandling(\n\tvalue,\n\tprecision,\n\te,\n\tnum,\n\tisDecimal,\n\tbits,\n\tceil,\n\troundingFunc,\n\tround,\n\texponent,\n) {\n\tif (typeof value === \"string\") {\n\t\tvalue = parseFloat(value);\n\t}\n\n\tlet result = value.toPrecision(precision);\n\n\tconst autoExponent = exponent === -1 || isNaN(exponent);\n\n\t// Handle scientific notation by recalculating with incremented exponent\n\tif (result.includes(E) && e < 8 && autoExponent) {\n\t\te++;\n\t\tconst { result: valueResult } = calculateOptimizedValue(num, e, isDecimal, bits, ceil);\n\t\tlet p;\n\t\tif (round > 0) {\n\t\t\tp = Math.pow(10, round);\n\t\t} else {\n\t\t\tp = 1;\n\t\t}\n\t\tlet computed;\n\t\tif (p === 1) {\n\t\t\tcomputed = roundingFunc(valueResult);\n\t\t} else {\n\t\t\tcomputed = roundingFunc(valueResult * p) / p;\n\t\t}\n\t\tresult = computed.toPrecision(precision);\n\t}\n\n\treturn { value: result, e };\n}\n\n/**\n * Optimized number formatting with locale, separator, and padding\n * @param {number|string} value - Value to format\n * @param {string|boolean} locale - Locale setting\n * @param {Object} localeOptions - Locale options\n * @param {string} separator - Custom separator\n * @param {boolean} pad - Whether to pad\n * @param {number} round - Round value\n * @returns {string|number} Formatted value\n */\nexport function applyNumberFormatting(value, locale, localeOptions, separator, pad, round) {\n\tlet result = value;\n\n\t// When padding alongside a locale, let the locale formatter emit the fixed\n\t// number of fraction digits. The manual string padding below cannot tell a\n\t// locale-inserted grouping separator from the decimal separator, so it\n\t// dropped digits (e.g. \"1,234,500\" became \"1,234\").\n\tconst localePad =\n\t\tpad && round > 0 ? { minimumFractionDigits: round, maximumFractionDigits: round } : undefined;\n\n\t// Apply locale formatting\n\tif (locale === true) {\n\t\tresult = result.toLocaleString(undefined, localePad);\n\t} else if (locale.length > 0) {\n\t\tresult = result.toLocaleString(locale, { ...localeOptions, ...localePad });\n\t} else if (separator.length > 0) {\n\t\tresult = result.toString().replace(PERIOD, separator);\n\t}\n\n\t// Apply padding for the non-locale paths, where the string has a single\n\t// decimal separator and no grouping is inserted.\n\tif (pad && round > 0 && locale !== true && locale.length === 0) {\n\t\tconst resultStr = result.toString();\n\t\tconst x = separator || PERIOD;\n\t\tconst tmp = resultStr.split(x);\n\t\tconst s = tmp[1] || EMPTY;\n\n\t\tresult = `${tmp[0]}${x}${s.padEnd(round, ZERO)}`;\n\t}\n\n\treturn result;\n}\n\n/**\n * Calculates exponent from the input value using pre-computed log values and clamps to supported range\n * Also adjusts precision when exponent exceeds the lookup table bounds\n * @param {number} num - Input file size in bytes\n * @param {number} e - Current exponent value\n * @param {number} exponent - Original user-provided exponent option (-1 for auto)\n * @param {boolean} isDecimal - Whether to use decimal (SI) base\n * @param {number} precision - Current precision value (modified when e > 8)\n * @returns {Object} Object with computed e value and possibly adjusted precision\n */\nexport function calculateExponent(num, e, exponent, isDecimal, precision) {\n\tif (e === -1 || isNaN(e)) {\n\t\tif (isDecimal) {\n\t\t\te = Math.floor(Math.log(num) / LOG_10_1000);\n\t\t} else {\n\t\t\te = Math.floor(Math.log(num) / LOG_2_1024);\n\t\t}\n\t\tif (e < 0) {\n\t\t\te = 0;\n\t\t}\n\t}\n\n\tif (e > 8) {\n\t\tif (precision > 0) {\n\t\t\tprecision += 8 - e;\n\t\t}\n\t\treturn { e: 8, precision };\n\t}\n\n\treturn { e, precision };\n}\n\n/**\n * Applies rounding to the raw calculated value and handles auto-increment ceiling\n * @param {number} val - Raw value before rounding\n * @param {number} ceil - Ceiling threshold (1000 for SI, 1024 for IEC)\n * @param {number} e - Current exponent value\n * @param {number} round - Number of decimal places\n * @param {Function} roundingFunc - Rounding method (Math.round, Math.floor, Math.ceil)\n * @param {boolean} autoExponent - Whether exponent is auto-calculated (-1 or NaN)\n * @returns {Object} Object with rounded value and possibly incremented exponent\n */\nexport function applyRounding(val, ceil, e, round, roundingFunc, autoExponent) {\n\tlet p;\n\tif (e > 0 && round > 0) {\n\t\tp = Math.pow(10, round);\n\t} else {\n\t\tp = 1;\n\t}\n\tlet r;\n\tif (p === 1) {\n\t\tr = roundingFunc(val);\n\t} else {\n\t\tr = roundingFunc(val * p) / p;\n\t}\n\n\tif (r === ceil && e < 8 && autoExponent) {\n\t\tr = 1;\n\t\te++;\n\t}\n\n\treturn { value: r, e };\n}\n\n/**\n * Resolves the unit symbol for the given standard, bits mode, and exponent\n * Handles SI standard special case where exponent 1 always uses \"kB\" or \"kbit\"\n * @param {string} actualStandard - The resolved standard (iec, jedec)\n * @param {boolean} bits - Whether formatting bit values\n * @param {number} e - Current exponent index\n * @param {boolean} isDecimal - Whether using decimal (SI) base\n * @returns {string} The resolved unit symbol string\n */\nexport function resolveSymbol(actualStandard, bits, e, isDecimal) {\n\tconst symbolTable = STRINGS.symbol[actualStandard][bits ? BITS : BYTES];\n\tlet result;\n\tif (isDecimal && e === 1) {\n\t\tif (bits) {\n\t\t\tresult = SI_KBIT;\n\t\t} else {\n\t\t\tresult = SI_KBYTE;\n\t\t}\n\t} else {\n\t\tresult = symbolTable[e];\n\t}\n\treturn result;\n}\n\n/**\n * Decorates the result: applies negation, custom symbols, number formatting, and full form names\n * Mutates the result array in-place for both value (index 0) and symbol (index 1)\n * @param {Array} result - Result array with numeric value at [0] and string symbol at [1]\n * @param {boolean} neg - Whether the original input was negative\n * @param {Object} symbols - Custom symbol override map\n * @param {string|boolean} locale - Locale string for formatting\n * @param {Object} localeOptions - Additional locale formatting options\n * @param {string} separator - Custom decimal separator\n * @param {boolean} pad - Whether zero-pad decimals\n * @param {number} round - Target decimal count for padding\n * @param {boolean} full - Whether to use full unit names\n * @param {Array} fullforms - Custom full unit name overrides\n * @param {string} actualStandard - Unit standard for full form lookup\n * @param {number} e - Current exponent index\n * @param {boolean} bits - Whether formatting bit values\n * @returns {void} Mutates result array in place\n */\nexport function decorateResult(\n\tresult,\n\tneg,\n\tsymbols,\n\tlocale,\n\tlocaleOptions,\n\tseparator,\n\tpad,\n\tround,\n\tfull,\n\tfullforms,\n\tactualStandard,\n\te,\n\tbits,\n) {\n\tif (neg) {\n\t\tresult[0] = -result[0];\n\t}\n\n\tif (symbols[result[1]]) {\n\t\tresult[1] = symbols[result[1]];\n\t}\n\n\tresult[0] = applyNumberFormatting(result[0], locale, localeOptions, separator, pad, round);\n\n\tif (full) {\n\t\tlet unit;\n\t\tif (bits) {\n\t\t\tunit = BIT;\n\t\t} else {\n\t\t\tunit = BYTE;\n\t\t}\n\t\tlet val;\n\t\tif (typeof result[0] === \"string\") {\n\t\t\tval = parseFloat(result[0]);\n\t\t} else {\n\t\t\tval = result[0];\n\t\t}\n\t\t// Determine singular/plural suffix\n\t\tlet suffix;\n\t\tif (val === 1) {\n\t\t\tsuffix = EMPTY;\n\t\t} else {\n\t\t\tsuffix = S;\n\t\t}\n\t\t// Determine symbol — custom fullforms are the complete name, defaults get unit+suffix\n\t\tif (fullforms[e]) {\n\t\t\tresult[1] = fullforms[e];\n\t\t} else {\n\t\t\tresult[1] = STRINGS.fullform[actualStandard][e] + unit + suffix;\n\t\t}\n\t}\n}\n\n/**\n * Formats the computed result array into the requested output type\n * @param {Array} result - Result array with formatted value at [0] and symbol at [1]\n * @param {number} e - Current exponent\n * @param {string} u - Original resolved symbol (before custom override)\n * @param {string} output - Output type (ARRAY, OBJECT, STRING)\n * @param {string} spacer - String separator between value and unit\n * @returns {string|Array|Object|number} Formatted result in requested type\n */\nexport function formatOutput(result, e, u, output, spacer) {\n\tif (output === ARRAY) {\n\t\treturn result;\n\t}\n\n\tif (output === OBJECT) {\n\t\treturn {\n\t\t\tvalue: result[0],\n\t\t\tsymbol: result[1],\n\t\t\texponent: e,\n\t\t\tunit: u,\n\t\t};\n\t}\n\n\tlet formatted;\n\tif (spacer === SPACE) {\n\t\tformatted = `${result[0]} ${result[1]}`;\n\t} else {\n\t\tformatted = result.join(spacer);\n\t}\n\treturn formatted;\n}\n","import {\n\tEMPTY,\n\tEXPONENT,\n\tFUNCTION,\n\tINVALID_NUMBER,\n\tINVALID_ROUND,\n\tROUND,\n\tSPACE,\n\tSTRING,\n} from \"./constants.js\";\nimport {\n\tapplyPrecisionHandling,\n\tapplyRounding,\n\tcalculateExponent,\n\tcalculateOptimizedValue,\n\tdecorateResult,\n\tformatOutput,\n\tgetBaseConfiguration,\n\thandleZeroValue,\n\tresolveSymbol,\n} from \"./helpers.js\";\n\n/**\n * Converts a file size in bytes to a human-readable string with appropriate units\n * @param {number|string|bigint} arg - The file size in bytes to convert\n * @param {Object} [options={}] - Configuration options for formatting\n * @param {boolean} [options.bits=false] - If true, calculates bits instead of bytes\n * @param {boolean} [options.pad=false] - If true, pads decimal places to match round parameter\n * @param {number} [options.base=-1] - Number base (2 for binary, 10 for decimal, -1 for auto)\n * @param {number} [options.round=2] - Number of decimal places to round to\n * @param {string|boolean} [options.locale=\"\"] - Locale for number formatting, true for system locale\n * @param {Object} [options.localeOptions={}] - Additional options for locale formatting\n * @param {string} [options.separator=\"\"] - Custom decimal separator\n * @param {string} [options.spacer=\" \"] - String to separate value and unit\n * @param {Object} [options.symbols={}] - Custom unit symbols\n * @param {string} [options.standard=\"\"] - Unit standard to use (SI, IEC, JEDEC)\n * @param {string} [options.output=\"string\"] - Output format: \"string\", \"array\", \"object\", or \"exponent\"\n * @param {boolean} [options.fullform=false] - If true, uses full unit names instead of abbreviations\n * @param {Array} [options.fullforms=[]] - Custom full unit names\n * @param {number} [options.exponent=-1] - Force specific exponent (-1 for auto)\n * @param {string} [options.roundingMethod=\"round\"] - Math rounding method to use\n * @param {number} [options.precision=0] - Number of significant digits (0 for auto)\n * @returns {string|Array|Object|number} Formatted file size based on output option\n * @throws {TypeError} When arg is not a valid number or roundingMethod is invalid\n * @example\n * filesize(1024) // \"1.02 kB\"\n * filesize(1024, {bits: true}) // \"8.19 kbit\"\n * filesize(1024, {output: \"object\"}) // {value: 1.02, symbol: \"kB\", exponent: 1, unit: \"kB\"}\n */\nexport function filesize(\n\targ,\n\t{\n\t\tbits = false,\n\t\tpad = false,\n\t\tbase = -1,\n\t\tround = 2,\n\t\tlocale = EMPTY,\n\t\tlocaleOptions = {},\n\t\tseparator = EMPTY,\n\t\tspacer = SPACE,\n\t\tsymbols = {},\n\t\tstandard = EMPTY,\n\t\toutput = STRING,\n\t\tfullform = false,\n\t\tfullforms = [],\n\t\texponent = -1,\n\t\troundingMethod = ROUND,\n\t\tprecision = 0,\n\t} = {},\n) {\n\tlet e = exponent,\n\t\tnum,\n\t\tresult = [],\n\t\tval = 0,\n\t\tu = EMPTY;\n\n\tif (typeof arg === \"bigint\") {\n\t\tnum = Number(arg);\n\t} else {\n\t\tnum = Number(arg);\n\n\t\tif (isNaN(arg)) {\n\t\t\tthrow new TypeError(INVALID_NUMBER);\n\t\t}\n\n\t\tif (!isFinite(num)) {\n\t\t\tthrow new TypeError(INVALID_NUMBER);\n\t\t}\n\t}\n\n\tconst { isDecimal, ceil, actualStandard } = getBaseConfiguration(standard, base);\n\n\tconst full = fullform === true,\n\t\tneg = num < 0,\n\t\troundingFunc = Math[roundingMethod];\n\n\tif (typeof roundingFunc !== FUNCTION) {\n\t\tthrow new TypeError(INVALID_ROUND);\n\t}\n\n\tif (neg) {\n\t\tnum = -num;\n\t}\n\n\tif (num === 0) {\n\t\treturn handleZeroValue(\n\t\t\tprecision,\n\t\t\tactualStandard,\n\t\t\tbits,\n\t\t\tsymbols,\n\t\t\tfull,\n\t\t\tfullforms,\n\t\t\toutput,\n\t\t\tspacer,\n\t\t);\n\t}\n\n\t// Exponent calculation + clamp + precision adjustment\n\tconst { e: calculatedE, precision: precisionAdjusted } = calculateExponent(\n\t\tnum,\n\t\te,\n\t\texponent,\n\t\tisDecimal,\n\t\tprecision,\n\t);\n\te = calculatedE;\n\tconst autoExponent = exponent === -1 || isNaN(exponent);\n\n\tif (output === EXPONENT) {\n\t\treturn e;\n\t}\n\n\tconst { result: valueResult, e: valueExponent } = calculateOptimizedValue(\n\t\tnum,\n\t\te,\n\t\tisDecimal,\n\t\tbits,\n\t\tceil,\n\t\tautoExponent,\n\t);\n\tval = valueResult;\n\te = valueExponent;\n\n\t// Rounding + auto-increment ceiling\n\tconst rounded = applyRounding(val, ceil, e, round, roundingFunc, autoExponent);\n\tresult[0] = rounded.value;\n\te = rounded.e;\n\n\t// Precision handling\n\tif (precisionAdjusted > 0) {\n\t\tconst precisionResult = applyPrecisionHandling(\n\t\t\tresult[0],\n\t\t\tprecisionAdjusted,\n\t\t\te,\n\t\t\tnum,\n\t\t\tisDecimal,\n\t\t\tbits,\n\t\t\tceil,\n\t\t\troundingFunc,\n\t\t\tround,\n\t\t\texponent,\n\t\t);\n\t\tresult[0] = precisionResult.value;\n\t\te = precisionResult.e;\n\t}\n\n\tu = resolveSymbol(actualStandard, bits, e, isDecimal);\n\tresult[1] = u;\n\n\tdecorateResult(\n\t\tresult,\n\t\tneg,\n\t\tsymbols,\n\t\tlocale,\n\t\tlocaleOptions,\n\t\tseparator,\n\t\tpad,\n\t\tround,\n\t\tfull,\n\t\tfullforms,\n\t\tactualStandard,\n\t\te,\n\t\tbits,\n\t);\n\n\treturn formatOutput(result, e, u, output, spacer);\n}\n\n/**\n * Creates a partially applied version of filesize with preset options\n * @param {Object} [options={}] - Configuration options (same as filesize)\n * @param {boolean} [options.bits=false] - If true, calculates bits instead of bytes\n * @param {boolean} [options.pad=false] - If true, pads decimal places to match round parameter\n * @param {number} [options.base=-1] - Number base (2 for binary, 10 for decimal, -1 for auto)\n * @param {number} [options.round=2] - Number of decimal places to round to\n * @param {string|boolean} [options.locale=\"\"] - Locale for number formatting, true for system locale\n * @param {Object} [options.localeOptions={}] - Additional options for locale formatting\n * @param {string} [options.separator=\"\"] - Custom decimal separator\n * @param {string} [options.spacer=\" \"] - String to separate value and unit\n * @param {Object} [options.symbols={}] - Custom unit symbols\n * @param {string} [options.standard=\"\"] - Unit standard to use (SI, IEC, JEDEC)\n * @param {string} [options.output=\"string\"] - Output format: \"string\", \"array\", \"object\", or \"exponent\"\n * @param {boolean} [options.fullform=false] - If true, uses full unit names instead of abbreviations\n * @param {Array} [options.fullforms=[]] - Custom full unit names\n * @param {number} [options.exponent=-1] - Force specific exponent (-1 for auto)\n * @param {string} [options.roundingMethod=\"round\"] - Math rounding method to use\n * @param {number} [options.precision=0] - Number of significant digits (0 for auto)\n * @returns {Function} A function that takes a file size and returns formatted output\n * @example\n * const formatBytes = partial({round: 1, standard: \"iec\"});\n * formatBytes(1024) // \"1 KiB\"\n * formatBytes(2048) // \"2 KiB\"\n * formatBytes(1536) // \"1.5 KiB\"\n */\nexport function partial({\n\tbits = false,\n\tpad = false,\n\tbase = -1,\n\tround = 2,\n\tlocale = EMPTY,\n\tseparator = EMPTY,\n\tspacer = SPACE,\n\tstandard = EMPTY,\n\toutput = STRING,\n\tfullform = false,\n\texponent = -1,\n\troundingMethod = ROUND,\n\tprecision = 0,\n\tlocaleOptions = {},\n\tsymbols = {},\n\tfullforms = [],\n} = {}) {\n\tconst cloned = {\n\t\tlocaleOptions: JSON.parse(JSON.stringify(localeOptions)),\n\t\tsymbols: JSON.parse(JSON.stringify(symbols)),\n\t\tfullforms: JSON.parse(JSON.stringify(fullforms)),\n\t};\n\n\treturn (arg) =>\n\t\tfilesize(arg, {\n\t\t\tbits,\n\t\t\tpad,\n\t\t\tbase,\n\t\t\tround,\n\t\t\tlocale,\n\t\t\tlocaleOptions: cloned.localeOptions,\n\t\t\tseparator,\n\t\t\tspacer,\n\t\t\tsymbols: cloned.symbols,\n\t\t\tstandard,\n\t\t\toutput,\n\t\t\tfullform,\n\t\t\tfullforms: cloned.fullforms,\n\t\t\texponent,\n\t\t\troundingMethod,\n\t\t\tprecision,\n\t\t});\n}\n"],"names":["g","f","exports","module","define","amd","globalThis","self","filesize","this","INVALID_NUMBER","IEC","JEDEC","SI","BYTE","ARRAY","OBJECT","STRING","EXPONENT","ROUND","STRINGS","symbol","iec","bits","bytes","jedec","fullform","BINARY_POWERS","DECIMAL_POWERS","LOG_2_1024","Math","log","LOG_10_1000","STANDARD_CONFIGS","isDecimal","ceil","actualStandard","calculateOptimizedValue","num","e","autoExponent","d","result","arg","pad","base","round","locale","EMPTY","localeOptions","separator","spacer","symbols","standard","output","fullforms","exponent","roundingMethod","precision","val","u","Number","isNaN","TypeError","isFinite","getBaseConfiguration","full","neg","roundingFunc","value","toPrecision","unit","handleZeroValue","calculatedE","precisionAdjusted","floor","calculateExponent","valueResult","valueExponent","rounded","p","r","pow","applyRounding","precisionResult","parseFloat","includes","computed","applyPrecisionHandling","symbolTable","resolveSymbol","localePad","minimumFractionDigits","maximumFractionDigits","undefined","toLocaleString","length","toString","replace","x","tmp","split","s","padEnd","applyNumberFormatting","suffix","decorateResult","formatted","join","formatOutput","partial","cloned","JSON","parse","stringify"],"mappings":";;;;CAAA,SAAAA,EAAAC,GAAA,iBAAAC,SAAA,oBAAAC,OAAAF,EAAAC,SAAA,mBAAAE,QAAAA,OAAAC,IAAAD,OAAA,CAAA,WAAAH,GAAAA,GAAAD,EAAA,oBAAAM,WAAAA,WAAAN,GAAAO,MAAAC,SAAA,CAAA,EAAA,CAAA,CAAAC,KAAA,SAAAP,GAAA,aACO,MAAMQ,EAAiB,iBAIjBC,EAAM,MACNC,EAAQ,QACRC,EAAK,KAKLC,EAAO,OAMPC,EAAQ,QAERC,EAAS,SACTC,EAAS,SAGTC,EAAW,WACXC,EAAQ,QAWRC,EAAU,CACtBC,OAAQ,CACPC,IAAK,CACJC,KAAM,CAAC,MAAO,QAAS,QAAS,QAAS,QAAS,QAAS,QAAS,QAAS,SAC7EC,MAAO,CAAC,IAAK,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,QAE/DC,MAAO,CACNF,KAAM,CAAC,MAAO,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,QACtEC,MAAO,CAAC,IAAK,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,QAGzDE,SAAU,CACTJ,IAAK,CAAC,GAAI,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,QAClEG,MAAO,CAAC,GAAI,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,MAAO,QAAS,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ACTA,EAASC,GAAKE,UACdA,EAAYF,GAAKG,OACjBA,EF7LoB,IE6LNE,SACdA,EAAWL,GAAKM,OAChBA,EAASrC,EAAMS,SACfA,GAAW,EAAK8B,SAChBA,GAAW,EAAEC,eACbA,EAAiBtC,EAAKuC,UACtBA,EAAY,EAACT,cACbA,EAAgB,CAAA,EAAEG,QAClBA,EAAU,CAAA,EAAEG,UACZA,EAAY,IACT,IACH,MAAMwD,EAAS,CACd9D,cAAe+D,KAAKC,MAAMD,KAAKE,UAAUjE,IACzCG,QAAS4D,KAAKC,MAAMD,KAAKE,UAAU9D,IACnCG,UAAWyD,KAAKC,MAAMD,KAAKE,UAAU3D,KAGtC,OAAQZ,GACPnC,EAASmC,EAAK,CACbpB,OACAqB,MACAC,OACAC,QACAC,SACAE,cAAe8D,EAAO9D,cACtBC,YACAC,SACAC,QAAS2D,EAAO3D,QAChBC,WACAC,SACA5B,WACA6B,UAAWwD,EAAOxD,UAClBC,WACAC,iBACAC,aAEH,CAAA"} diff --git a/package-lock.json b/package-lock.json index 6408274..34a542e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "filesize", - "version": "11.0.17", + "version": "11.0.18", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "filesize", - "version": "11.0.17", + "version": "11.0.18", "license": "BSD-3-Clause", "devDependencies": { "@rollup/plugin-terser": "^1.0.0", diff --git a/package.json b/package.json index 7a870f1..9a3456d 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.17", + "version": "11.0.18", "homepage": "https://filesizejs.com", "author": "Jason Mulligan ", "repository": {