From c02b5d366d617278126e9be1bd51c60f75f15c5d Mon Sep 17 00:00:00 2001 From: Jason Mulligan Date: Thu, 9 Jul 2026 07:45:15 -0400 Subject: [PATCH] chore: build v11.0.22 artifacts --- dist/filesize.cjs | 20 ++++++++++++-------- dist/filesize.js | 20 ++++++++++++-------- dist/filesize.min.js | 4 ++-- dist/filesize.min.js.map | 2 +- dist/filesize.umd.js | 20 ++++++++++++-------- dist/filesize.umd.min.js | 4 ++-- dist/filesize.umd.min.js.map | 2 +- 7 files changed, 42 insertions(+), 30 deletions(-) diff --git a/dist/filesize.cjs b/dist/filesize.cjs index afe6c8b..3e0ff94 100644 --- a/dist/filesize.cjs +++ b/dist/filesize.cjs @@ -3,7 +3,7 @@ * * @copyright 2026 Jason Mulligan * @license BSD-3-Clause - * @version 11.0.21 + * @version 11.0.22 */ 'use strict'; @@ -475,6 +475,16 @@ function decorateResult( result[1] = symbols[result[1]]; } + // Capture the numeric value before formatting; a comma decimal separator + // (via separator or a locale such as de-DE) would otherwise make parseFloat + // read "1,5" as 1 and select the singular unit name. + let numericValue; + if (typeof result[0] === "string") { + numericValue = parseFloat(result[0]); + } else { + numericValue = result[0]; + } + result[0] = applyNumberFormatting( result[0], locale, @@ -492,15 +502,9 @@ function decorateResult( } else { unit = BYTE; } - let val; - if (typeof result[0] === "string") { - val = parseFloat(result[0]); - } else { - val = result[0]; - } // Determine singular/plural suffix let suffix; - if (val === 1) { + if (numericValue === 1) { suffix = EMPTY; } else { suffix = S; diff --git a/dist/filesize.js b/dist/filesize.js index 2077345..1faad84 100644 --- a/dist/filesize.js +++ b/dist/filesize.js @@ -3,7 +3,7 @@ * * @copyright 2026 Jason Mulligan * @license BSD-3-Clause - * @version 11.0.21 + * @version 11.0.22 */ // Error Messages const INVALID_NUMBER = "Invalid number"; @@ -471,6 +471,16 @@ function decorateResult( result[1] = symbols[result[1]]; } + // Capture the numeric value before formatting; a comma decimal separator + // (via separator or a locale such as de-DE) would otherwise make parseFloat + // read "1,5" as 1 and select the singular unit name. + let numericValue; + if (typeof result[0] === "string") { + numericValue = parseFloat(result[0]); + } else { + numericValue = result[0]; + } + result[0] = applyNumberFormatting( result[0], locale, @@ -488,15 +498,9 @@ function decorateResult( } else { unit = BYTE; } - let val; - if (typeof result[0] === "string") { - val = parseFloat(result[0]); - } else { - val = result[0]; - } // Determine singular/plural suffix let suffix; - if (val === 1) { + if (numericValue === 1) { suffix = EMPTY; } else { suffix = S; diff --git a/dist/filesize.min.js b/dist/filesize.min.js index 01dc089..82c4f10 100644 --- a/dist/filesize.min.js +++ b/dist/filesize.min.js @@ -1,5 +1,5 @@ /*! 2026 Jason Mulligan - @version 11.0.21 + @version 11.0.22 */ -const t="Invalid number",e="iec",i="jedec",n="si",o="byte",r="array",a="object",s="string",l="exponent",u="round",c={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}},b=[1,1024,1048576,1073741824,1099511627776,0x4000000000000,0x1000000000000000,11805916207174113e5,12089258196146292e8],f=[1,1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24],d=Math.log(1024),p=Math.log(1e3),m={[n]:{isDecimal:!0,ceil:1e3,actualStandard:i},[e]:{isDecimal:!1,ceil:1024,actualStandard:e},[i]:{isDecimal:!1,ceil:1024,actualStandard:i}};function y(t,e,i,n,o,r=!0){let a;a=i?f[e]:b[e];let s=t/a;return n&&(s*=8,r&&s>=o&&e<8&&(s/=o,e++)),{result:s,e:e}}function B(n,{bits:b=!1,pad:f=!1,base:B=-1,round:h=2,locale:M="",localeOptions:g={},separator:N="",spacer:x=" ",symbols:S={},standard:v="",output:D=s,fullform:O=!1,fullforms:E=[],exponent:T=-1,roundingMethod:w=u,precision:F=0}={}){let $,j=T,k=[],G=0,J="";if("bigint"==typeof n)$=Number(n);else{if($=Number(n),isNaN($))throw new TypeError(t);if(!isFinite($))throw new TypeError(t)}const{isDecimal:K,ceil:P,actualStandard:Y}=function(t,n){return m[t]?m[t]:2===n?{isDecimal:!1,ceil:1024,actualStandard:e}:{isDecimal:!0,ceil:1e3,actualStandard:i}}(v,B),Z=!0===O,z=$<0,C=Math[w];if("function"!=typeof C)throw new TypeError("Invalid rounding method");if(z&&($=-$),0===$)return function(t,e,i,n,s,u,b,f,d,p,m){let y;return y=t>0?(0).toPrecision(t):d&&p>0?(0).toFixed(p):0,b===l?0:(m||(m=i?c.symbol[e].bits[0]:c.symbol[e].bytes[0]),n[m]&&(m=n[m]),s&&(u[0]?m=u[0]:(m=c.fullform[e][0],m+=i?"bit":o)),b===r?[y,m]:b===a?{value:y,symbol:m,exponent:0,unit:m}:y+f+m)}(F,Y,b,S,Z,E,D,x,f,h);const{e:I,precision:q}=function(t,e,i,n,o){return-1===e||isNaN(e)?(e=n?Math.floor(Math.log(t)/p):Math.floor(Math.log(t)/d))<0&&(e=0):e<0&&(e=0),e>8?(o>0&&(o+=8-e),{e:8,precision:o}):{e:e,precision:o}}($,j,0,K,F);j=I;const A=-1===T||isNaN(T),{result:H,e:L}=y($,j,K,b,P,A);G=H,j=L;const Q=function(t,e,i,n,o,r){let a,s;return a=i>0&&n>0?Math.pow(10,n):1,s=1===a?o(t):o(t*a)/a,s===e&&i<8&&r&&(s=1,i++),{value:s,e:i}}(G,P,j,h,C,A);if(k[0]=Q.value,j=Q.e,q>0){const t=function(t,e,i,n,o,r,a,s,l,u){"string"==typeof t&&(t=parseFloat(t));let c=t.toPrecision(e);const b=-1===u||isNaN(u);if(c.includes("e")&&i<8&&b){i++;const{result:t}=y(n,i,o,r,a);let u,b;u=l>0?Math.pow(10,l):1,b=1===u?s(t):s(t*u)/u,c=b.toPrecision(e)}return{value:c,e:i}}(k[0],q,j,$,K,b,P,C,h,T);k[0]=t.value,j=t.e}return D===l?j:(J=function(t,e,i,n){const o=c.symbol[t][e?"bits":"bytes"];let r;return r=n&&1===i?e?"kbit":"kB":o[i],r}(Y,b,j,K),k[1]=J,function(t,e,i,n,r,a,s,l,u,b,f,d,p,m){if(e&&(t[0]=-t[0]),i[t[1]]&&(t[1]=i[t[1]]),t[0]=function(t,e,i,n,o,r,a){let s=t;const l=o&&r>0?{minimumFractionDigits:r,maximumFractionDigits:r}:void 0;if(!0===e)s=s.toLocaleString(void 0,l);else if(e.length>0)s=s.toLocaleString(e,{...i,...l});else if(n.length>0){if(o&&r>0){const t=Math.pow(10,r);s=a(s*t)/t}s=s.toString().replace(".",n)}if(o&&r>0&&!0!==e&&0===e.length){const t=n||".",e=s.toString().split(t),i=e[1]||"";s=`${e[0]}${t}${i.padEnd(r,"0")}`}return s}(t[0],n,r,a,s,l,m),u){let e,i,n;e=p?"bit":o,i="string"==typeof t[0]?parseFloat(t[0]):t[0],n=1===i?"":"s",b[d]?t[1]=b[d]:t[1]=c.fullform[f][d]+e+n}}(k,z,S,M,g,N,f,h,Z,E,Y,j,b,C),function(t,e,i,n,o){if(n===r)return t;if(n===a)return{value:t[0],symbol:t[1],exponent:e,unit:i};let s;return s=" "===o?`${t[0]} ${t[1]}`:t.join(o),s}(k,j,J,D,x))}function h({bits:t=!1,pad:e=!1,base:i=-1,round:n=2,locale:o="",separator:r="",spacer:a=" ",standard:l="",output:c=s,fullform:b=!1,exponent:f=-1,roundingMethod:d=u,precision:p=0,localeOptions:m={},symbols:y={},fullforms:h=[]}={}){function M(t){try{return"function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t))}catch{return JSON.parse(JSON.stringify(t))}}const g={localeOptions:M(m),symbols:M(y),fullforms:M(h)};return s=>B(s,{bits:t,pad:e,base:i,round:n,locale:o,localeOptions:g.localeOptions,separator:r,spacer:a,symbols:g.symbols,standard:l,output:c,fullform:b,fullforms:g.fullforms,exponent:f,roundingMethod:d,precision:p})}export{B as filesize,h as partial};//# sourceMappingURL=filesize.min.js.map +const t="Invalid number",e="iec",i="jedec",n="si",o="byte",r="array",a="object",s="string",l="exponent",u="round",c={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}},b=[1,1024,1048576,1073741824,1099511627776,0x4000000000000,0x1000000000000000,11805916207174113e5,12089258196146292e8],f=[1,1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24],d=Math.log(1024),p=Math.log(1e3),m={[n]:{isDecimal:!0,ceil:1e3,actualStandard:i},[e]:{isDecimal:!1,ceil:1024,actualStandard:e},[i]:{isDecimal:!1,ceil:1024,actualStandard:i}};function y(t,e,i,n,o,r=!0){let a;a=i?f[e]:b[e];let s=t/a;return n&&(s*=8,r&&s>=o&&e<8&&(s/=o,e++)),{result:s,e:e}}function B(n,{bits:b=!1,pad:f=!1,base:B=-1,round:h=2,locale:M="",localeOptions:g={},separator:N="",spacer:x=" ",symbols:S={},standard:v="",output:D=s,fullform:O=!1,fullforms:E=[],exponent:T=-1,roundingMethod:w=u,precision:F=0}={}){let $,j=T,k=[],G=0,J="";if("bigint"==typeof n)$=Number(n);else{if($=Number(n),isNaN($))throw new TypeError(t);if(!isFinite($))throw new TypeError(t)}const{isDecimal:K,ceil:P,actualStandard:Y}=function(t,n){return m[t]?m[t]:2===n?{isDecimal:!1,ceil:1024,actualStandard:e}:{isDecimal:!0,ceil:1e3,actualStandard:i}}(v,B),Z=!0===O,z=$<0,C=Math[w];if("function"!=typeof C)throw new TypeError("Invalid rounding method");if(z&&($=-$),0===$)return function(t,e,i,n,s,u,b,f,d,p,m){let y;return y=t>0?(0).toPrecision(t):d&&p>0?(0).toFixed(p):0,b===l?0:(m||(m=i?c.symbol[e].bits[0]:c.symbol[e].bytes[0]),n[m]&&(m=n[m]),s&&(u[0]?m=u[0]:(m=c.fullform[e][0],m+=i?"bit":o)),b===r?[y,m]:b===a?{value:y,symbol:m,exponent:0,unit:m}:y+f+m)}(F,Y,b,S,Z,E,D,x,f,h);const{e:I,precision:q}=function(t,e,i,n,o){return-1===e||isNaN(e)?(e=n?Math.floor(Math.log(t)/p):Math.floor(Math.log(t)/d))<0&&(e=0):e<0&&(e=0),e>8?(o>0&&(o+=8-e),{e:8,precision:o}):{e:e,precision:o}}($,j,0,K,F);j=I;const A=-1===T||isNaN(T),{result:H,e:L}=y($,j,K,b,P,A);G=H,j=L;const Q=function(t,e,i,n,o,r){let a,s;return a=i>0&&n>0?Math.pow(10,n):1,s=1===a?o(t):o(t*a)/a,s===e&&i<8&&r&&(s=1,i++),{value:s,e:i}}(G,P,j,h,C,A);if(k[0]=Q.value,j=Q.e,q>0){const t=function(t,e,i,n,o,r,a,s,l,u){"string"==typeof t&&(t=parseFloat(t));let c=t.toPrecision(e);const b=-1===u||isNaN(u);if(c.includes("e")&&i<8&&b){i++;const{result:t}=y(n,i,o,r,a);let u,b;u=l>0?Math.pow(10,l):1,b=1===u?s(t):s(t*u)/u,c=b.toPrecision(e)}return{value:c,e:i}}(k[0],q,j,$,K,b,P,C,h,T);k[0]=t.value,j=t.e}return D===l?j:(J=function(t,e,i,n){const o=c.symbol[t][e?"bits":"bytes"];let r;return r=n&&1===i?e?"kbit":"kB":o[i],r}(Y,b,j,K),k[1]=J,function(t,e,i,n,r,a,s,l,u,b,f,d,p,m){let y;if(e&&(t[0]=-t[0]),i[t[1]]&&(t[1]=i[t[1]]),y="string"==typeof t[0]?parseFloat(t[0]):t[0],t[0]=function(t,e,i,n,o,r,a){let s=t;const l=o&&r>0?{minimumFractionDigits:r,maximumFractionDigits:r}:void 0;if(!0===e)s=s.toLocaleString(void 0,l);else if(e.length>0)s=s.toLocaleString(e,{...i,...l});else if(n.length>0){if(o&&r>0){const t=Math.pow(10,r);s=a(s*t)/t}s=s.toString().replace(".",n)}if(o&&r>0&&!0!==e&&0===e.length){const t=n||".",e=s.toString().split(t),i=e[1]||"";s=`${e[0]}${t}${i.padEnd(r,"0")}`}return s}(t[0],n,r,a,s,l,m),u){let e,i;e=p?"bit":o,i=1===y?"":"s",b[d]?t[1]=b[d]:t[1]=c.fullform[f][d]+e+i}}(k,z,S,M,g,N,f,h,Z,E,Y,j,b,C),function(t,e,i,n,o){if(n===r)return t;if(n===a)return{value:t[0],symbol:t[1],exponent:e,unit:i};let s;return s=" "===o?`${t[0]} ${t[1]}`:t.join(o),s}(k,j,J,D,x))}function h({bits:t=!1,pad:e=!1,base:i=-1,round:n=2,locale:o="",separator:r="",spacer:a=" ",standard:l="",output:c=s,fullform:b=!1,exponent:f=-1,roundingMethod:d=u,precision:p=0,localeOptions:m={},symbols:y={},fullforms:h=[]}={}){function M(t){try{return"function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t))}catch{return JSON.parse(JSON.stringify(t))}}const g={localeOptions:M(m),symbols:M(y),fullforms:M(h)};return s=>B(s,{bits:t,pad:e,base:i,round:n,locale:o,localeOptions:g.localeOptions,separator:r,spacer:a,symbols:g.symbols,standard:l,output:c,fullform:b,fullforms:g.fullforms,exponent:f,roundingMethod:d,precision:p})}export{B as filesize,h as partial};//# sourceMappingURL=filesize.min.js.map diff --git a/dist/filesize.min.js.map b/dist/filesize.min.js.map index a076328..b875f30 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 {boolean} pad - Whether to pad decimal places\n * @param {number} round - Number of decimal places for padding\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\tpad,\n\tround,\n\tsymbol,\n) {\n\tlet value;\n\tif (precision > 0) {\n\t\tvalue = (0).toPrecision(precision);\n\t} else if (pad && round > 0) {\n\t\tvalue = (0).toFixed(round);\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(\n\tvalue,\n\tlocale,\n\tlocaleOptions,\n\tseparator,\n\tpad,\n\tround,\n\troundingFunc,\n) {\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\t// Round before separator replacement to ensure excess decimal places\n\t\t// are truncated when pad is also set (fixes padding + separator bug).\n\t\tif (pad && round > 0) {\n\t\t\tconst p = Math.pow(10, round);\n\t\t\tresult = roundingFunc(result * p) / p;\n\t\t}\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} else if (e < 0) {\n\t\t// A forced exponent below the auto sentinel (-1) has no meaning and\n\t\t// would otherwise index the power-of-ten/two lookup tables out of\n\t\t// bounds (producing NaN). Clamp to 0, mirroring the e > 8 clamp below.\n\t\te = 0;\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\troundingFunc,\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(\n\t\tresult[0],\n\t\tlocale,\n\t\tlocaleOptions,\n\t\tseparator,\n\t\tpad,\n\t\tround,\n\t\troundingFunc,\n\t);\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(num)) {\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\tpad,\n\t\t\tround,\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\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\t// Return the exponent only after every adjustment that other output\n\t// modes apply (bits auto-increment, rounding overflow, precision), so\n\t// it always matches the exponent reported by object output.\n\tif (output === EXPONENT) {\n\t\treturn 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\troundingFunc,\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\t/**\n\t * Safely clone an object using structuredClone with JSON fallback.\n\t * structuredClone can throw for functions, circular refs, etc.\n\t */\n\tfunction safeClone(value) {\n\t\ttry {\n\t\t\treturn typeof structuredClone === \"function\"\n\t\t\t\t? structuredClone(value)\n\t\t\t\t: JSON.parse(JSON.stringify(value));\n\t\t} catch {\n\t\t\treturn JSON.parse(JSON.stringify(value));\n\t\t}\n\t}\n\n\tconst cloned = {\n\t\tlocaleOptions: safeClone(localeOptions),\n\t\tsymbols: safeClone(symbols),\n\t\tfullforms: safeClone(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","toFixed","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","safeClone","structuredClone","JSON","parse","stringify","cloned"],"mappings":";;;;AACO,MAAMA,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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IgD,EAMJ,OAJCA,ED5bmB,MC2bhBzD,EACS,GAAGV,EAAO,MAAMA,EAAO,KAEvBA,EAAOoE,KAAK1D,GAElByD,CACR,CClSQE,CAAarE,EAAQH,EAAGsB,EAAGN,EAAQH,GAC3C,CA4BO,SAAS4D,GAAQzF,KACvBA,GAAO,EAAKsB,IACZA,GAAM,EAAKC,KACXA,GAAO,EAAEC,MACTA,EAAQ,EAACC,OACTA,EAASC,GAAKE,UACdA,EAAYF,GAAKG,OACjBA,EFnMoB,IEmMNE,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,IAKH,SAASyD,EAAU3C,GAClB,IACC,MAAkC,mBAApB4C,gBACXA,gBAAgB5C,GAChB6C,KAAKC,MAAMD,KAAKE,UAAU/C,GAC9B,CAAE,MACD,OAAO6C,KAAKC,MAAMD,KAAKE,UAAU/C,GAClC,CACD,CAEA,MAAMgD,EAAS,CACdpE,cAAe+D,EAAU/D,GACzBG,QAAS4D,EAAU5D,GACnBG,UAAWyD,EAAUzD,IAGtB,OAAQZ,GACPD,EAASC,EAAK,CACbrB,OACAsB,MACAC,OACAC,QACAC,SACAE,cAAeoE,EAAOpE,cACtBC,YACAC,SACAC,QAASiE,EAAOjE,QAChBC,WACAC,SACA7B,WACA8B,UAAW8D,EAAO9D,UAClBC,WACAC,iBACAC,aAEH,QAAAhB,cAAAqE"} +{"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 {boolean} pad - Whether to pad decimal places\n * @param {number} round - Number of decimal places for padding\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\tpad,\n\tround,\n\tsymbol,\n) {\n\tlet value;\n\tif (precision > 0) {\n\t\tvalue = (0).toPrecision(precision);\n\t} else if (pad && round > 0) {\n\t\tvalue = (0).toFixed(round);\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(\n\tvalue,\n\tlocale,\n\tlocaleOptions,\n\tseparator,\n\tpad,\n\tround,\n\troundingFunc,\n) {\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\t// Round before separator replacement to ensure excess decimal places\n\t\t// are truncated when pad is also set (fixes padding + separator bug).\n\t\tif (pad && round > 0) {\n\t\t\tconst p = Math.pow(10, round);\n\t\t\tresult = roundingFunc(result * p) / p;\n\t\t}\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} else if (e < 0) {\n\t\t// A forced exponent below the auto sentinel (-1) has no meaning and\n\t\t// would otherwise index the power-of-ten/two lookup tables out of\n\t\t// bounds (producing NaN). Clamp to 0, mirroring the e > 8 clamp below.\n\t\te = 0;\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\troundingFunc,\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\t// Capture the numeric value before formatting; a comma decimal separator\n\t// (via separator or a locale such as de-DE) would otherwise make parseFloat\n\t// read \"1,5\" as 1 and select the singular unit name.\n\tlet numericValue;\n\tif (typeof result[0] === \"string\") {\n\t\tnumericValue = parseFloat(result[0]);\n\t} else {\n\t\tnumericValue = result[0];\n\t}\n\n\tresult[0] = applyNumberFormatting(\n\t\tresult[0],\n\t\tlocale,\n\t\tlocaleOptions,\n\t\tseparator,\n\t\tpad,\n\t\tround,\n\t\troundingFunc,\n\t);\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\t// Determine singular/plural suffix\n\t\tlet suffix;\n\t\tif (numericValue === 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(num)) {\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\tpad,\n\t\t\tround,\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\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\t// Return the exponent only after every adjustment that other output\n\t// modes apply (bits auto-increment, rounding overflow, precision), so\n\t// it always matches the exponent reported by object output.\n\tif (output === EXPONENT) {\n\t\treturn 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\troundingFunc,\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\t/**\n\t * Safely clone an object using structuredClone with JSON fallback.\n\t * structuredClone can throw for functions, circular refs, etc.\n\t */\n\tfunction safeClone(value) {\n\t\ttry {\n\t\t\treturn typeof structuredClone === \"function\"\n\t\t\t\t? structuredClone(value)\n\t\t\t\t: JSON.parse(JSON.stringify(value));\n\t\t} catch {\n\t\t\treturn JSON.parse(JSON.stringify(value));\n\t\t}\n\t}\n\n\tconst cloned = {\n\t\tlocaleOptions: safeClone(localeOptions),\n\t\tsymbols: safeClone(symbols),\n\t\tfullforms: safeClone(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","toFixed","unit","handleZeroValue","calculatedE","precisionAdjusted","floor","calculateExponent","valueResult","valueExponent","rounded","p","r","pow","applyRounding","precisionResult","parseFloat","includes","computed","applyPrecisionHandling","symbolTable","resolveSymbol","numericValue","localePad","minimumFractionDigits","maximumFractionDigits","undefined","toLocaleString","length","toString","replace","x","tmp","split","s","padEnd","applyNumberFormatting","suffix","decorateResult","formatted","join","formatOutput","partial","safeClone","structuredClone","JSON","parse","stringify","cloned"],"mappings":";;;;AACO,MAAMA,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,OA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,OAJCA,EDhcmB,MC+bhB1D,EACS,GAAGV,EAAO,MAAMA,EAAO,KAEvBA,EAAOqE,KAAK3D,GAElB0D,CACR,CCtSQE,CAAatE,EAAQH,EAAGsB,EAAGN,EAAQH,GAC3C,CA4BO,SAAS6D,GAAQ1F,KACvBA,GAAO,EAAKsB,IACZA,GAAM,EAAKC,KACXA,GAAO,EAAEC,MACTA,EAAQ,EAACC,OACTA,EAASC,GAAKE,UACdA,EAAYF,GAAKG,OACjBA,EFnMoB,IEmMNE,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,IAKH,SAAS0D,EAAU5C,GAClB,IACC,MAAkC,mBAApB6C,gBACXA,gBAAgB7C,GAChB8C,KAAKC,MAAMD,KAAKE,UAAUhD,GAC9B,CAAE,MACD,OAAO8C,KAAKC,MAAMD,KAAKE,UAAUhD,GAClC,CACD,CAEA,MAAMiD,EAAS,CACdrE,cAAegE,EAAUhE,GACzBG,QAAS6D,EAAU7D,GACnBG,UAAW0D,EAAU1D,IAGtB,OAAQZ,GACPD,EAASC,EAAK,CACbrB,OACAsB,MACAC,OACAC,QACAC,SACAE,cAAeqE,EAAOrE,cACtBC,YACAC,SACAC,QAASkE,EAAOlE,QAChBC,WACAC,SACA7B,WACA8B,UAAW+D,EAAO/D,UAClBC,WACAC,iBACAC,aAEH,QAAAhB,cAAAsE"} diff --git a/dist/filesize.umd.js b/dist/filesize.umd.js index ed1b4d7..a493061 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.21 + * @version 11.0.22 */ (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"; @@ -471,6 +471,16 @@ function decorateResult( result[1] = symbols[result[1]]; } + // Capture the numeric value before formatting; a comma decimal separator + // (via separator or a locale such as de-DE) would otherwise make parseFloat + // read "1,5" as 1 and select the singular unit name. + let numericValue; + if (typeof result[0] === "string") { + numericValue = parseFloat(result[0]); + } else { + numericValue = result[0]; + } + result[0] = applyNumberFormatting( result[0], locale, @@ -488,15 +498,9 @@ function decorateResult( } else { unit = BYTE; } - let val; - if (typeof result[0] === "string") { - val = parseFloat(result[0]); - } else { - val = result[0]; - } // Determine singular/plural suffix let suffix; - if (val === 1) { + if (numericValue === 1) { suffix = EMPTY; } else { suffix = S; diff --git a/dist/filesize.umd.min.js b/dist/filesize.umd.min.js index 7ba9356..383fd35 100644 --- a/dist/filesize.umd.min.js +++ b/dist/filesize.umd.min.js @@ -1,5 +1,5 @@ /*! 2026 Jason Mulligan - @version 11.0.21 + @version 11.0.22 */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).filesize={})}(this,function(t){"use strict";const e="Invalid number",i="iec",n="jedec",o="si",r="byte",a="array",s="object",l="string",u="exponent",c="round",f={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}},b=[1,1024,1048576,1073741824,1099511627776,0x4000000000000,0x1000000000000000,11805916207174113e5,12089258196146292e8],d=[1,1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24],p=Math.log(1024),m=Math.log(1e3),y={[o]:{isDecimal:!0,ceil:1e3,actualStandard:n},[i]:{isDecimal:!1,ceil:1024,actualStandard:i},[n]:{isDecimal:!1,ceil:1024,actualStandard:n}};function h(t,e,i,n,o,r=!0){let a;a=i?d[e]:b[e];let s=t/a;return n&&(s*=8,r&&s>=o&&e<8&&(s/=o,e++)),{result:s,e:e}}function B(t,{bits:o=!1,pad:b=!1,base:d=-1,round:B=2,locale:M="",localeOptions:g={},separator:x="",spacer:N=" ",symbols:S={},standard:T="",output:v=l,fullform:D=!1,fullforms:O=[],exponent:E=-1,roundingMethod:w=c,precision:j=0}={}){let F,$=E,k=[],G=0,J="";if("bigint"==typeof t)F=Number(t);else{if(F=Number(t),isNaN(F))throw new TypeError(e);if(!isFinite(F))throw new TypeError(e)}const{isDecimal:K,ceil:P,actualStandard:Y}=function(t,e){return y[t]?y[t]:2===e?{isDecimal:!1,ceil:1024,actualStandard:i}:{isDecimal:!0,ceil:1e3,actualStandard:n}}(T,d),Z=!0===D,z=F<0,C=Math[w];if("function"!=typeof C)throw new TypeError("Invalid rounding method");if(z&&(F=-F),0===F)return function(t,e,i,n,o,l,c,b,d,p,m){let y;return y=t>0?(0).toPrecision(t):d&&p>0?(0).toFixed(p):0,c===u?0:(m||(m=i?f.symbol[e].bits[0]:f.symbol[e].bytes[0]),n[m]&&(m=n[m]),o&&(l[0]?m=l[0]:(m=f.fullform[e][0],m+=i?"bit":r)),c===a?[y,m]:c===s?{value:y,symbol:m,exponent:0,unit:m}:y+b+m)}(j,Y,o,S,Z,O,v,N,b,B);const{e:I,precision:q}=function(t,e,i,n,o){return-1===e||isNaN(e)?(e=n?Math.floor(Math.log(t)/m):Math.floor(Math.log(t)/p))<0&&(e=0):e<0&&(e=0),e>8?(o>0&&(o+=8-e),{e:8,precision:o}):{e:e,precision:o}}(F,$,0,K,j);$=I;const A=-1===E||isNaN(E),{result:H,e:L}=h(F,$,K,o,P,A);G=H,$=L;const Q=function(t,e,i,n,o,r){let a,s;return a=i>0&&n>0?Math.pow(10,n):1,s=1===a?o(t):o(t*a)/a,s===e&&i<8&&r&&(s=1,i++),{value:s,e:i}}(G,P,$,B,C,A);if(k[0]=Q.value,$=Q.e,q>0){const t=function(t,e,i,n,o,r,a,s,l,u){"string"==typeof t&&(t=parseFloat(t));let c=t.toPrecision(e);const f=-1===u||isNaN(u);if(c.includes("e")&&i<8&&f){i++;const{result:t}=h(n,i,o,r,a);let u,f;u=l>0?Math.pow(10,l):1,f=1===u?s(t):s(t*u)/u,c=f.toPrecision(e)}return{value:c,e:i}}(k[0],q,$,F,K,o,P,C,B,E);k[0]=t.value,$=t.e}return v===u?$:(J=function(t,e,i,n){const o=f.symbol[t][e?"bits":"bytes"];let r;return r=n&&1===i?e?"kbit":"kB":o[i],r}(Y,o,$,K),k[1]=J,function(t,e,i,n,o,a,s,l,u,c,b,d,p,m){if(e&&(t[0]=-t[0]),i[t[1]]&&(t[1]=i[t[1]]),t[0]=function(t,e,i,n,o,r,a){let s=t;const l=o&&r>0?{minimumFractionDigits:r,maximumFractionDigits:r}:void 0;if(!0===e)s=s.toLocaleString(void 0,l);else if(e.length>0)s=s.toLocaleString(e,{...i,...l});else if(n.length>0){if(o&&r>0){const t=Math.pow(10,r);s=a(s*t)/t}s=s.toString().replace(".",n)}if(o&&r>0&&!0!==e&&0===e.length){const t=n||".",e=s.toString().split(t),i=e[1]||"";s=`${e[0]}${t}${i.padEnd(r,"0")}`}return s}(t[0],n,o,a,s,l,m),u){let e,i,n;e=p?"bit":r,i="string"==typeof t[0]?parseFloat(t[0]):t[0],n=1===i?"":"s",c[d]?t[1]=c[d]:t[1]=f.fullform[b][d]+e+n}}(k,z,S,M,g,x,b,B,Z,O,Y,$,o,C),function(t,e,i,n,o){if(n===a)return t;if(n===s)return{value:t[0],symbol:t[1],exponent:e,unit:i};let r;return r=" "===o?`${t[0]} ${t[1]}`:t.join(o),r}(k,$,J,v,N))}t.filesize=B,t.partial=function({bits:t=!1,pad:e=!1,base:i=-1,round:n=2,locale:o="",separator:r="",spacer:a=" ",standard:s="",output:u=l,fullform:f=!1,exponent:b=-1,roundingMethod:d=c,precision:p=0,localeOptions:m={},symbols:y={},fullforms:h=[]}={}){function M(t){try{return"function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t))}catch{return JSON.parse(JSON.stringify(t))}}const g={localeOptions:M(m),symbols:M(y),fullforms:M(h)};return l=>B(l,{bits:t,pad:e,base:i,round:n,locale:o,localeOptions:g.localeOptions,separator:r,spacer:a,symbols:g.symbols,standard:s,output:u,fullform:f,fullforms:g.fullforms,exponent:b,roundingMethod:d,precision:p})}});//# sourceMappingURL=filesize.umd.min.js.map +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).filesize={})}(this,function(t){"use strict";const e="Invalid number",i="iec",n="jedec",o="si",r="byte",a="array",s="object",l="string",u="exponent",c="round",f={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}},b=[1,1024,1048576,1073741824,1099511627776,0x4000000000000,0x1000000000000000,11805916207174113e5,12089258196146292e8],d=[1,1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24],p=Math.log(1024),m=Math.log(1e3),y={[o]:{isDecimal:!0,ceil:1e3,actualStandard:n},[i]:{isDecimal:!1,ceil:1024,actualStandard:i},[n]:{isDecimal:!1,ceil:1024,actualStandard:n}};function h(t,e,i,n,o,r=!0){let a;a=i?d[e]:b[e];let s=t/a;return n&&(s*=8,r&&s>=o&&e<8&&(s/=o,e++)),{result:s,e:e}}function B(t,{bits:o=!1,pad:b=!1,base:d=-1,round:B=2,locale:M="",localeOptions:g={},separator:x="",spacer:N=" ",symbols:S={},standard:T="",output:v=l,fullform:D=!1,fullforms:O=[],exponent:E=-1,roundingMethod:w=c,precision:j=0}={}){let F,$=E,k=[],G=0,J="";if("bigint"==typeof t)F=Number(t);else{if(F=Number(t),isNaN(F))throw new TypeError(e);if(!isFinite(F))throw new TypeError(e)}const{isDecimal:K,ceil:P,actualStandard:Y}=function(t,e){return y[t]?y[t]:2===e?{isDecimal:!1,ceil:1024,actualStandard:i}:{isDecimal:!0,ceil:1e3,actualStandard:n}}(T,d),Z=!0===D,z=F<0,C=Math[w];if("function"!=typeof C)throw new TypeError("Invalid rounding method");if(z&&(F=-F),0===F)return function(t,e,i,n,o,l,c,b,d,p,m){let y;return y=t>0?(0).toPrecision(t):d&&p>0?(0).toFixed(p):0,c===u?0:(m||(m=i?f.symbol[e].bits[0]:f.symbol[e].bytes[0]),n[m]&&(m=n[m]),o&&(l[0]?m=l[0]:(m=f.fullform[e][0],m+=i?"bit":r)),c===a?[y,m]:c===s?{value:y,symbol:m,exponent:0,unit:m}:y+b+m)}(j,Y,o,S,Z,O,v,N,b,B);const{e:I,precision:q}=function(t,e,i,n,o){return-1===e||isNaN(e)?(e=n?Math.floor(Math.log(t)/m):Math.floor(Math.log(t)/p))<0&&(e=0):e<0&&(e=0),e>8?(o>0&&(o+=8-e),{e:8,precision:o}):{e:e,precision:o}}(F,$,0,K,j);$=I;const A=-1===E||isNaN(E),{result:H,e:L}=h(F,$,K,o,P,A);G=H,$=L;const Q=function(t,e,i,n,o,r){let a,s;return a=i>0&&n>0?Math.pow(10,n):1,s=1===a?o(t):o(t*a)/a,s===e&&i<8&&r&&(s=1,i++),{value:s,e:i}}(G,P,$,B,C,A);if(k[0]=Q.value,$=Q.e,q>0){const t=function(t,e,i,n,o,r,a,s,l,u){"string"==typeof t&&(t=parseFloat(t));let c=t.toPrecision(e);const f=-1===u||isNaN(u);if(c.includes("e")&&i<8&&f){i++;const{result:t}=h(n,i,o,r,a);let u,f;u=l>0?Math.pow(10,l):1,f=1===u?s(t):s(t*u)/u,c=f.toPrecision(e)}return{value:c,e:i}}(k[0],q,$,F,K,o,P,C,B,E);k[0]=t.value,$=t.e}return v===u?$:(J=function(t,e,i,n){const o=f.symbol[t][e?"bits":"bytes"];let r;return r=n&&1===i?e?"kbit":"kB":o[i],r}(Y,o,$,K),k[1]=J,function(t,e,i,n,o,a,s,l,u,c,b,d,p,m){let y;if(e&&(t[0]=-t[0]),i[t[1]]&&(t[1]=i[t[1]]),y="string"==typeof t[0]?parseFloat(t[0]):t[0],t[0]=function(t,e,i,n,o,r,a){let s=t;const l=o&&r>0?{minimumFractionDigits:r,maximumFractionDigits:r}:void 0;if(!0===e)s=s.toLocaleString(void 0,l);else if(e.length>0)s=s.toLocaleString(e,{...i,...l});else if(n.length>0){if(o&&r>0){const t=Math.pow(10,r);s=a(s*t)/t}s=s.toString().replace(".",n)}if(o&&r>0&&!0!==e&&0===e.length){const t=n||".",e=s.toString().split(t),i=e[1]||"";s=`${e[0]}${t}${i.padEnd(r,"0")}`}return s}(t[0],n,o,a,s,l,m),u){let e,i;e=p?"bit":r,i=1===y?"":"s",c[d]?t[1]=c[d]:t[1]=f.fullform[b][d]+e+i}}(k,z,S,M,g,x,b,B,Z,O,Y,$,o,C),function(t,e,i,n,o){if(n===a)return t;if(n===s)return{value:t[0],symbol:t[1],exponent:e,unit:i};let r;return r=" "===o?`${t[0]} ${t[1]}`:t.join(o),r}(k,$,J,v,N))}t.filesize=B,t.partial=function({bits:t=!1,pad:e=!1,base:i=-1,round:n=2,locale:o="",separator:r="",spacer:a=" ",standard:s="",output:u=l,fullform:f=!1,exponent:b=-1,roundingMethod:d=c,precision:p=0,localeOptions:m={},symbols:y={},fullforms:h=[]}={}){function M(t){try{return"function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t))}catch{return JSON.parse(JSON.stringify(t))}}const g={localeOptions:M(m),symbols:M(y),fullforms:M(h)};return l=>B(l,{bits:t,pad:e,base:i,round:n,locale:o,localeOptions:g.localeOptions,separator:r,spacer:a,symbols:g.symbols,standard:s,output:u,fullform:f,fullforms:g.fullforms,exponent:b,roundingMethod:d,precision:p})}});//# sourceMappingURL=filesize.umd.min.js.map diff --git a/dist/filesize.umd.min.js.map b/dist/filesize.umd.min.js.map index a0ca8e1..99859b3 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 {boolean} pad - Whether to pad decimal places\n * @param {number} round - Number of decimal places for padding\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\tpad,\n\tround,\n\tsymbol,\n) {\n\tlet value;\n\tif (precision > 0) {\n\t\tvalue = (0).toPrecision(precision);\n\t} else if (pad && round > 0) {\n\t\tvalue = (0).toFixed(round);\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(\n\tvalue,\n\tlocale,\n\tlocaleOptions,\n\tseparator,\n\tpad,\n\tround,\n\troundingFunc,\n) {\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\t// Round before separator replacement to ensure excess decimal places\n\t\t// are truncated when pad is also set (fixes padding + separator bug).\n\t\tif (pad && round > 0) {\n\t\t\tconst p = Math.pow(10, round);\n\t\t\tresult = roundingFunc(result * p) / p;\n\t\t}\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} else if (e < 0) {\n\t\t// A forced exponent below the auto sentinel (-1) has no meaning and\n\t\t// would otherwise index the power-of-ten/two lookup tables out of\n\t\t// bounds (producing NaN). Clamp to 0, mirroring the e > 8 clamp below.\n\t\te = 0;\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\troundingFunc,\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(\n\t\tresult[0],\n\t\tlocale,\n\t\tlocaleOptions,\n\t\tseparator,\n\t\tpad,\n\t\tround,\n\t\troundingFunc,\n\t);\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(num)) {\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\tpad,\n\t\t\tround,\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\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\t// Return the exponent only after every adjustment that other output\n\t// modes apply (bits auto-increment, rounding overflow, precision), so\n\t// it always matches the exponent reported by object output.\n\tif (output === EXPONENT) {\n\t\treturn 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\troundingFunc,\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\t/**\n\t * Safely clone an object using structuredClone with JSON fallback.\n\t * structuredClone can throw for functions, circular refs, etc.\n\t */\n\tfunction safeClone(value) {\n\t\ttry {\n\t\t\treturn typeof structuredClone === \"function\"\n\t\t\t\t? structuredClone(value)\n\t\t\t\t: JSON.parse(JSON.stringify(value));\n\t\t} catch {\n\t\t\treturn JSON.parse(JSON.stringify(value));\n\t\t}\n\t}\n\n\tconst cloned = {\n\t\tlocaleOptions: safeClone(localeOptions),\n\t\tsymbols: safeClone(symbols),\n\t\tfullforms: safeClone(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","toFixed","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","safeClone","structuredClone","JSON","parse","stringify","cloned"],"mappings":";;;;CAAA,SA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bA,EAAiBtC,EAAKuC,UACtBA,EAAY,EAACT,cACbA,EAAgB,CAAA,EAAEG,QAClBA,EAAU,CAAA,EAAEG,UACZA,EAAY,IACT,IAKH,SAASyD,EAAU3C,GAClB,IACC,MAAkC,mBAApB4C,gBACXA,gBAAgB5C,GAChB6C,KAAKC,MAAMD,KAAKE,UAAU/C,GAC9B,CAAE,MACD,OAAO6C,KAAKC,MAAMD,KAAKE,UAAU/C,GAClC,CACD,CAEA,MAAMgD,EAAS,CACdpE,cAAe+D,EAAU/D,GACzBG,QAAS4D,EAAU5D,GACnBG,UAAWyD,EAAUzD,IAGtB,OAAQZ,GACPnC,EAASmC,EAAK,CACbpB,OACAqB,MACAC,OACAC,QACAC,SACAE,cAAeoE,EAAOpE,cACtBC,YACAC,SACAC,QAASiE,EAAOjE,QAChBC,WACAC,SACA5B,WACA6B,UAAW8D,EAAO9D,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 {boolean} pad - Whether to pad decimal places\n * @param {number} round - Number of decimal places for padding\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\tpad,\n\tround,\n\tsymbol,\n) {\n\tlet value;\n\tif (precision > 0) {\n\t\tvalue = (0).toPrecision(precision);\n\t} else if (pad && round > 0) {\n\t\tvalue = (0).toFixed(round);\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(\n\tvalue,\n\tlocale,\n\tlocaleOptions,\n\tseparator,\n\tpad,\n\tround,\n\troundingFunc,\n) {\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\t// Round before separator replacement to ensure excess decimal places\n\t\t// are truncated when pad is also set (fixes padding + separator bug).\n\t\tif (pad && round > 0) {\n\t\t\tconst p = Math.pow(10, round);\n\t\t\tresult = roundingFunc(result * p) / p;\n\t\t}\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} else if (e < 0) {\n\t\t// A forced exponent below the auto sentinel (-1) has no meaning and\n\t\t// would otherwise index the power-of-ten/two lookup tables out of\n\t\t// bounds (producing NaN). Clamp to 0, mirroring the e > 8 clamp below.\n\t\te = 0;\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\troundingFunc,\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\t// Capture the numeric value before formatting; a comma decimal separator\n\t// (via separator or a locale such as de-DE) would otherwise make parseFloat\n\t// read \"1,5\" as 1 and select the singular unit name.\n\tlet numericValue;\n\tif (typeof result[0] === \"string\") {\n\t\tnumericValue = parseFloat(result[0]);\n\t} else {\n\t\tnumericValue = result[0];\n\t}\n\n\tresult[0] = applyNumberFormatting(\n\t\tresult[0],\n\t\tlocale,\n\t\tlocaleOptions,\n\t\tseparator,\n\t\tpad,\n\t\tround,\n\t\troundingFunc,\n\t);\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\t// Determine singular/plural suffix\n\t\tlet suffix;\n\t\tif (numericValue === 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(num)) {\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\tpad,\n\t\t\tround,\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\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\t// Return the exponent only after every adjustment that other output\n\t// modes apply (bits auto-increment, rounding overflow, precision), so\n\t// it always matches the exponent reported by object output.\n\tif (output === EXPONENT) {\n\t\treturn 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\troundingFunc,\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\t/**\n\t * Safely clone an object using structuredClone with JSON fallback.\n\t * structuredClone can throw for functions, circular refs, etc.\n\t */\n\tfunction safeClone(value) {\n\t\ttry {\n\t\t\treturn typeof structuredClone === \"function\"\n\t\t\t\t? structuredClone(value)\n\t\t\t\t: JSON.parse(JSON.stringify(value));\n\t\t} catch {\n\t\t\treturn JSON.parse(JSON.stringify(value));\n\t\t}\n\t}\n\n\tconst cloned = {\n\t\tlocaleOptions: safeClone(localeOptions),\n\t\tsymbols: safeClone(symbols),\n\t\tfullforms: safeClone(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","toFixed","unit","handleZeroValue","calculatedE","precisionAdjusted","floor","calculateExponent","valueResult","valueExponent","rounded","p","r","pow","applyRounding","precisionResult","parseFloat","includes","computed","applyPrecisionHandling","symbolTable","resolveSymbol","numericValue","localePad","minimumFractionDigits","maximumFractionDigits","undefined","toLocaleString","length","toString","replace","x","tmp","split","s","padEnd","applyNumberFormatting","suffix","decorateResult","formatted","join","formatOutput","partial","safeClone","structuredClone","JSON","parse","stringify","cloned"],"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,EACA,IACA,IACA,IACA,KACA,KACA,KACA,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