From b7e36e6744adc81051c1592573a1de2782680865 Mon Sep 17 00:00:00 2001 From: Jason Mulligan Date: Fri, 19 Sep 2025 08:34:24 -0400 Subject: [PATCH 1/2] Fixing the upper boundary of 'precision' (#204) --- dist/filesize.cjs | 2 +- dist/filesize.js | 2 +- dist/filesize.min.js | 2 +- dist/filesize.min.js.map | 2 +- dist/filesize.umd.js | 2 +- dist/filesize.umd.min.js | 2 +- dist/filesize.umd.min.js.map | 2 +- src/filesize.js | 2 +- tests/unit/filesize.test.js | 71 +++++++++++++++++++++++++++++++++++- 9 files changed, 77 insertions(+), 10 deletions(-) diff --git a/dist/filesize.cjs b/dist/filesize.cjs index 2705344..5589339 100644 --- a/dist/filesize.cjs +++ b/dist/filesize.cjs @@ -198,7 +198,7 @@ function filesize (arg, { if (precision > 0) { result[0] = result[0].toPrecision(precision); - if (result[0].includes(E)) { + if (result[0].includes(E) && e < 8) { e++; d = base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e); val = num / d; diff --git a/dist/filesize.js b/dist/filesize.js index 0fbf35c..8cc8be6 100644 --- a/dist/filesize.js +++ b/dist/filesize.js @@ -194,7 +194,7 @@ function filesize (arg, { if (precision > 0) { result[0] = result[0].toPrecision(precision); - if (result[0].includes(E)) { + if (result[0].includes(E) && e < 8) { e++; d = base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e); val = num / d; diff --git a/dist/filesize.min.js b/dist/filesize.min.js index 311e205..d2d22b0 100644 --- a/dist/filesize.min.js +++ b/dist/filesize.min.js @@ -2,4 +2,4 @@ 2025 Jason Mulligan @version 11.0.6 */ -const t="jedec",i="bits",e="bytes",o="string",n="round",r="",a={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"]}};function l(l,{bits:s=!1,pad:b=!1,base:p=-1,round:c=2,locale:u="",localeOptions:d={},separator:f="",spacer:g=" ",symbols:m={},standard:h="",output:B=o,fullform:y=!1,fullforms:M=[],exponent:w=-1,roundingMethod:x=n,precision:E=0}={}){let P=w,T=Number(l),j=[],N=0,S=r;"si"===h?(p=10,h=t):"iec"===h||h===t?p=2:2===p?h="iec":(p=10,h=t);const k=10===p?1e3:1024,G=!0===y,K=T<0,Y=Math[x];if("bigint"!=typeof l&&isNaN(l))throw new TypeError("Invalid number");if("function"!=typeof Y)throw new TypeError("Invalid rounding method");if(K&&(T=-T),(-1===P||isNaN(P))&&(P=Math.floor(Math.log(T)/Math.log(k)),P<0&&(P=0)),P>8&&(E>0&&(E+=8-P),P=8),"exponent"===B)return P;if(0===T)j[0]=0,E>0&&(j[0]=j[0].toPrecision(E)),S=j[1]=a.symbol[h][s?i:e][P];else{let t=2===p?Math.pow(2,10*P):Math.pow(1e3,P);N=T/t,s&&(N*=8,N>=k&&P<8&&(N/=k,P++));let o=Math.pow(10,P>0?c:0);j[0]=Y(N*o)/o,j[0]===k&&P<8&&-1===w&&(j[0]=1,P++),E>0&&(j[0]=j[0].toPrecision(E),j[0].includes("e")&&(P++,t=2===p?Math.pow(2,10*P):Math.pow(1e3,P),N=T/t,j[0]=Y(N*o)/o)),S=j[1]=10===p&&1===P?s?"kbit":"kB":a.symbol[h][s?i:e][P]}if(K&&(j[0]=-j[0]),j[1]=m[j[1]]||j[1],!0===u?j[0]=j[0].toLocaleString():u.length>0?j[0]=j[0].toLocaleString(u,d):f.length>0&&(j[0]=j[0].toString().replace(".",f)),b&&c>0){const t=j[0].toString(),i=f||(t.match(/(\D)/g)||[]).pop()||".",e=t.toString().split(i),o=e[1]||r,n=o.length,a=c-n;j[0]=`${e[0]}${i}${o.padEnd(n+a,"0")}`}return G&&(j[1]=M[P]?M[P]:a.fullform[h][P]+(s?"bit":"byte")+(1===j[0]?r:"s")),"array"===B?j:"object"===B?{value:j[0],symbol:j[1],exponent:P,unit:S}:j.join(g)}function s({bits:t=!1,pad:i=!1,base:e=-1,round:r=2,locale:a="",localeOptions:s={},separator:b="",spacer:p=" ",symbols:c={},standard:u="",output:d=o,fullform:f=!1,fullforms:g=[],exponent:m=-1,roundingMethod:h=n,precision:B=0}={}){return o=>l(o,{bits:t,pad:i,base:e,round:r,locale:a,localeOptions:s,separator:b,spacer:p,symbols:c,standard:u,output:d,fullform:f,fullforms:g,exponent:m,roundingMethod:h,precision:B})}export{l as filesize,s as partial};//# sourceMappingURL=filesize.min.js.map +const t="jedec",i="bits",e="bytes",o="string",n="round",r="",a={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"]}};function l(l,{bits:s=!1,pad:b=!1,base:p=-1,round:c=2,locale:u="",localeOptions:d={},separator:f="",spacer:g=" ",symbols:m={},standard:h="",output:B=o,fullform:y=!1,fullforms:M=[],exponent:w=-1,roundingMethod:x=n,precision:E=0}={}){let P=w,T=Number(l),j=[],N=0,S=r;"si"===h?(p=10,h=t):"iec"===h||h===t?p=2:2===p?h="iec":(p=10,h=t);const k=10===p?1e3:1024,G=!0===y,K=T<0,Y=Math[x];if("bigint"!=typeof l&&isNaN(l))throw new TypeError("Invalid number");if("function"!=typeof Y)throw new TypeError("Invalid rounding method");if(K&&(T=-T),(-1===P||isNaN(P))&&(P=Math.floor(Math.log(T)/Math.log(k)),P<0&&(P=0)),P>8&&(E>0&&(E+=8-P),P=8),"exponent"===B)return P;if(0===T)j[0]=0,E>0&&(j[0]=j[0].toPrecision(E)),S=j[1]=a.symbol[h][s?i:e][P];else{let t=2===p?Math.pow(2,10*P):Math.pow(1e3,P);N=T/t,s&&(N*=8,N>=k&&P<8&&(N/=k,P++));let o=Math.pow(10,P>0?c:0);j[0]=Y(N*o)/o,j[0]===k&&P<8&&-1===w&&(j[0]=1,P++),E>0&&(j[0]=j[0].toPrecision(E),j[0].includes("e")&&P<8&&(P++,t=2===p?Math.pow(2,10*P):Math.pow(1e3,P),N=T/t,j[0]=Y(N*o)/o)),S=j[1]=10===p&&1===P?s?"kbit":"kB":a.symbol[h][s?i:e][P]}if(K&&(j[0]=-j[0]),j[1]=m[j[1]]||j[1],!0===u?j[0]=j[0].toLocaleString():u.length>0?j[0]=j[0].toLocaleString(u,d):f.length>0&&(j[0]=j[0].toString().replace(".",f)),b&&c>0){const t=j[0].toString(),i=f||(t.match(/(\D)/g)||[]).pop()||".",e=t.toString().split(i),o=e[1]||r,n=o.length,a=c-n;j[0]=`${e[0]}${i}${o.padEnd(n+a,"0")}`}return G&&(j[1]=M[P]?M[P]:a.fullform[h][P]+(s?"bit":"byte")+(1===j[0]?r:"s")),"array"===B?j:"object"===B?{value:j[0],symbol:j[1],exponent:P,unit:S}:j.join(g)}function s({bits:t=!1,pad:i=!1,base:e=-1,round:r=2,locale:a="",localeOptions:s={},separator:b="",spacer:p=" ",symbols:c={},standard:u="",output:d=o,fullform:f=!1,fullforms:g=[],exponent:m=-1,roundingMethod:h=n,precision:B=0}={}){return o=>l(o,{bits:t,pad:i,base:e,round:r,locale:a,localeOptions:s,separator:b,spacer:p,symbols:c,standard:u,output:d,fullform:f,fullforms:g,exponent:m,roundingMethod:h,precision:B})}export{l as filesize,s as partial};//# sourceMappingURL=filesize.min.js.map diff --git a/dist/filesize.min.js.map b/dist/filesize.min.js.map index c57376b..71ea707 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/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","import {\n\tARRAY,\n\tBIT,\n\tBITS,\n\tBYTE,\n\tBYTES,\n\tE,\n\tEMPTY,\n\tEXPONENT,\n\tFUNCTION,\n\tIEC,\n\tINVALID_NUMBER,\n\tINVALID_ROUND,\n\tJEDEC,\n\tOBJECT,\n\tPERIOD,\n\tROUND,\n\tS,\n\tSI,\n\tSI_KBIT,\n\tSI_KBYTE,\n\tSPACE,\n\tSTRING,\n\tSTRINGS,\n\tZERO\n} from \"./constants.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 KB\"\n * filesize(1024, {bits: true}) // \"8 Kb\"\n * filesize(1024, {output: \"object\"}) // {value: 1, symbol: \"KB\", exponent: 1, unit: \"KB\"}\n */\nexport function filesize (arg, {\n\tbits = false,\n\tpad = false,\n\tbase = -1,\n\tround = 2,\n\tlocale = EMPTY,\n\tlocaleOptions = {},\n\tseparator = EMPTY,\n\tspacer = SPACE,\n\tsymbols = {},\n\tstandard = EMPTY,\n\toutput = STRING,\n\tfullform = false,\n\tfullforms = [],\n\texponent = -1,\n\troundingMethod = ROUND,\n\tprecision = 0\n} = {}) {\n\tlet e = exponent,\n\t\tnum = Number(arg),\n\t\tresult = [],\n\t\tval = 0,\n\t\tu = EMPTY;\n\n\t// Sync base & standard\n\tif (standard === SI) {\n\t\tbase = 10;\n\t\tstandard = JEDEC;\n\t} else if (standard === IEC || standard === JEDEC) {\n\t\tbase = 2;\n\t} else if (base === 2) {\n\t\tstandard = IEC;\n\t} else {\n\t\tbase = 10;\n\t\tstandard = JEDEC;\n\t}\n\n\tconst ceil = base === 10 ? 1000 : 1024,\n\t\tfull = fullform === true,\n\t\tneg = num < 0,\n\t\troundingFunc = Math[roundingMethod];\n\n\tif (typeof arg !== \"bigint\" && isNaN(arg)) {\n\t\tthrow new TypeError(INVALID_NUMBER);\n\t}\n\n\tif (typeof roundingFunc !== FUNCTION) {\n\t\tthrow new TypeError(INVALID_ROUND);\n\t}\n\n\t// Flipping a negative number to determine the size\n\tif (neg) {\n\t\tnum = -num;\n\t}\n\n\t// Determining the exponent\n\tif (e === -1 || isNaN(e)) {\n\t\te = Math.floor(Math.log(num) / Math.log(ceil));\n\n\t\tif (e < 0) {\n\t\t\te = 0;\n\t\t}\n\t}\n\n\t// Exceeding supported length, time to reduce & multiply\n\tif (e > 8) {\n\t\tif (precision > 0) {\n\t\t\tprecision += 8 - e;\n\t\t}\n\n\t\te = 8;\n\t}\n\n\tif (output === EXPONENT) {\n\t\treturn e;\n\t}\n\n\t// Zero is now a special case because bytes divide by 1\n\tif (num === 0) {\n\t\tresult[0] = 0;\n\n\t\tif (precision > 0) {\n\t\t\tresult[0] = result[0].toPrecision(precision);\n\t\t}\n\n\t\tu = result[1] = STRINGS.symbol[standard][bits ? BITS : BYTES][e];\n\t} else {\n\t\tlet d = base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e);\n\t\tval = num / d;\n\n\t\tif (bits) {\n\t\t\tval = val * 8;\n\n\t\t\tif (val >= ceil && e < 8) {\n\t\t\t\tval = val / ceil;\n\t\t\t\te++;\n\t\t\t}\n\t\t}\n\n\t\tlet p = Math.pow(10, e > 0 ? round : 0);\n\t\tresult[0] = roundingFunc(val * p) / p;\n\n\t\tif (result[0] === ceil && e < 8 && exponent === -1) {\n\t\t\tresult[0] = 1;\n\t\t\te++;\n\t\t}\n\n\t\t// Setting optional precision\n\t\tif (precision > 0) {\n\t\t\tresult[0] = result[0].toPrecision(precision);\n\n\t\t\tif (result[0].includes(E)) {\n\t\t\t\te++;\n\t\t\t\td = base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e);\n\t\t\t\tval = num / d;\n\t\t\t\tresult[0] = roundingFunc(val * p) / p;\n\t\t\t}\n\t\t}\n\n\t\tu = result[1] = base === 10 && e === 1 ? bits ? SI_KBIT : SI_KBYTE : STRINGS.symbol[standard][bits ? BITS : BYTES][e];\n\t}\n\n\t// Decorating a 'diff'\n\tif (neg) {\n\t\tresult[0] = -result[0];\n\t}\n\n\t// Applying custom symbol\n\tresult[1] = symbols[result[1]] || result[1];\n\n\tif (locale === true) {\n\t\tresult[0] = result[0].toLocaleString();\n\t} else if (locale.length > 0) {\n\t\tresult[0] = result[0].toLocaleString(locale, localeOptions);\n\t} else if (separator.length > 0) {\n\t\tresult[0] = result[0].toString().replace(PERIOD, separator);\n\t}\n\n\tif (pad && round > 0) {\n\t\tconst i = result[0].toString(),\n\t\t\tx = separator || ((i.match(/(\\D)/g) || []).pop() || PERIOD),\n\t\t\ttmp = i.toString().split(x),\n\t\t\ts = tmp[1] || EMPTY,\n\t\t\tl = s.length,\n\t\t\tn = round - l;\n\n\t\tresult[0] = `${tmp[0]}${x}${s.padEnd(l + n, ZERO)}`;\n\t}\n\n\tif (full) {\n\t\tresult[1] = fullforms[e] ? fullforms[e] : STRINGS.fullform[standard][e] + (bits ? BIT : BYTE) + (result[0] === 1 ? EMPTY : S);\n\t}\n\n\t// Returning Array, Object, or String (default)\n\treturn output === ARRAY ? result : output === OBJECT ? {\n\t\tvalue: result[0],\n\t\tsymbol: result[1],\n\t\texponent: e,\n\t\tunit: u\n\t} : result.join(spacer);\n}\n\n/**\n * Creates a partially applied version of filesize with preset options\n * @param {Object} [options={}] - Default options to apply to the returned function\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.0 KiB\"\n * formatBytes(2048) // \"2.0 KiB\"\n */\n// Partial application for functional programming\nexport function partial ({\n\tbits = false,\n\tpad = false,\n\tbase = -1,\n\tround = 2,\n\tlocale = EMPTY,\n\tlocaleOptions = {},\n\tseparator = EMPTY,\n\tspacer = SPACE,\n\tsymbols = {},\n\tstandard = EMPTY,\n\toutput = STRING,\n\tfullform = false,\n\tfullforms = [],\n\texponent = -1,\n\troundingMethod = ROUND,\n\tprecision = 0\n} = {}) {\n\treturn arg => filesize(arg, {\n\t\tbits,\n\t\tpad,\n\t\tbase,\n\t\tround,\n\t\tlocale,\n\t\tlocaleOptions,\n\t\tseparator,\n\t\tspacer,\n\t\tsymbols,\n\t\tstandard,\n\t\toutput,\n\t\tfullform,\n\t\tfullforms,\n\t\texponent,\n\t\troundingMethod,\n\t\tprecision\n\t});\n}\n"],"names":["JEDEC","BITS","BYTES","STRING","ROUND","EMPTY","STRINGS","symbol","iec","bits","bytes","jedec","fullform","filesize","arg","pad","base","round","locale","localeOptions","separator","spacer","symbols","standard","output","fullforms","exponent","roundingMethod","precision","e","num","Number","result","val","u","ceil","full","neg","roundingFunc","Math","isNaN","TypeError","floor","log","toPrecision","d","pow","p","includes","toLocaleString","length","toString","replace","i","x","match","pop","tmp","split","s","l","n","padEnd","value","unit","join","partial"],"mappings":";;;;AACO,MAKMA,EAAQ,QAKRC,EAAO,OAEPC,EAAQ,QAQRC,EAAS,SAITC,EAAQ,QAIRC,EAAQ,GAORC,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,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F,WAAWO,MAAMJ,GACzBK,EAAIF,EAAI,IAAMpD,EACduD,EAAID,EAAET,OACNW,EAAI5C,EAAQ2C,EAEb5B,EAAO,GAAK,GAAGyB,EAAI,KAAKH,IAAIK,EAAEG,OAAOF,EAAIC,EDvKvB,MCwKnB,CAOA,OALIzB,IACHJ,EAAO,GAAKP,EAAUI,GAAKJ,EAAUI,GAAKvB,EAAQM,SAASW,GAAUM,IAAMpB,EDlM1D,MAEC,SCgM6F,IAAduB,EAAO,GAAW3B,ED7KpG,MAbI,UC8LbmB,EAAmBQ,ED5LL,WC4LcR,EAAoB,CACtDuC,MAAO/B,EAAO,GACdzB,OAAQyB,EAAO,GACfN,SAAUG,EACVmC,KAAM9B,GACHF,EAAOiC,KAAK5C,EACjB,CA4BO,SAAS6C,GAASzD,KACxBA,GAAO,EAAKM,IACZA,GAAM,EAAKC,KACXA,GAAO,EAAEC,MACTA,EAAQ,EAACC,OACTA,EAASb,GAAKc,cACdA,EAAgB,CAAA,EAAEC,UAClBA,EAAYf,GAAKgB,OACjBA,ED1NoB,IC0NNC,QACdA,EAAU,CAAA,EAAEC,SACZA,EAAWlB,GAAKmB,OAChBA,EAASrB,EAAMS,SACfA,GAAW,EAAKa,UAChBA,EAAY,GAAEC,SACdA,GAAW,EAAEC,eACbA,EAAiBvB,EAAKwB,UACtBA,EAAY,GACT,IACH,OAAOd,GAAOD,EAASC,EAAK,CAC3BL,OACAM,MACAC,OACAC,QACAC,SACAC,gBACAC,YACAC,SACAC,UACAC,WACAC,SACAZ,WACAa,YACAC,WACAC,iBACAC,aAEF,QAAAf,cAAAqD"} \ No newline at end of file +{"version":3,"file":"filesize.min.js","sources":["../src/constants.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","import {\n\tARRAY,\n\tBIT,\n\tBITS,\n\tBYTE,\n\tBYTES,\n\tE,\n\tEMPTY,\n\tEXPONENT,\n\tFUNCTION,\n\tIEC,\n\tINVALID_NUMBER,\n\tINVALID_ROUND,\n\tJEDEC,\n\tOBJECT,\n\tPERIOD,\n\tROUND,\n\tS,\n\tSI,\n\tSI_KBIT,\n\tSI_KBYTE,\n\tSPACE,\n\tSTRING,\n\tSTRINGS,\n\tZERO\n} from \"./constants.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 KB\"\n * filesize(1024, {bits: true}) // \"8 Kb\"\n * filesize(1024, {output: \"object\"}) // {value: 1, symbol: \"KB\", exponent: 1, unit: \"KB\"}\n */\nexport function filesize (arg, {\n\tbits = false,\n\tpad = false,\n\tbase = -1,\n\tround = 2,\n\tlocale = EMPTY,\n\tlocaleOptions = {},\n\tseparator = EMPTY,\n\tspacer = SPACE,\n\tsymbols = {},\n\tstandard = EMPTY,\n\toutput = STRING,\n\tfullform = false,\n\tfullforms = [],\n\texponent = -1,\n\troundingMethod = ROUND,\n\tprecision = 0\n} = {}) {\n\tlet e = exponent,\n\t\tnum = Number(arg),\n\t\tresult = [],\n\t\tval = 0,\n\t\tu = EMPTY;\n\n\t// Sync base & standard\n\tif (standard === SI) {\n\t\tbase = 10;\n\t\tstandard = JEDEC;\n\t} else if (standard === IEC || standard === JEDEC) {\n\t\tbase = 2;\n\t} else if (base === 2) {\n\t\tstandard = IEC;\n\t} else {\n\t\tbase = 10;\n\t\tstandard = JEDEC;\n\t}\n\n\tconst ceil = base === 10 ? 1000 : 1024,\n\t\tfull = fullform === true,\n\t\tneg = num < 0,\n\t\troundingFunc = Math[roundingMethod];\n\n\tif (typeof arg !== \"bigint\" && isNaN(arg)) {\n\t\tthrow new TypeError(INVALID_NUMBER);\n\t}\n\n\tif (typeof roundingFunc !== FUNCTION) {\n\t\tthrow new TypeError(INVALID_ROUND);\n\t}\n\n\t// Flipping a negative number to determine the size\n\tif (neg) {\n\t\tnum = -num;\n\t}\n\n\t// Determining the exponent\n\tif (e === -1 || isNaN(e)) {\n\t\te = Math.floor(Math.log(num) / Math.log(ceil));\n\n\t\tif (e < 0) {\n\t\t\te = 0;\n\t\t}\n\t}\n\n\t// Exceeding supported length, time to reduce & multiply\n\tif (e > 8) {\n\t\tif (precision > 0) {\n\t\t\tprecision += 8 - e;\n\t\t}\n\n\t\te = 8;\n\t}\n\n\tif (output === EXPONENT) {\n\t\treturn e;\n\t}\n\n\t// Zero is now a special case because bytes divide by 1\n\tif (num === 0) {\n\t\tresult[0] = 0;\n\n\t\tif (precision > 0) {\n\t\t\tresult[0] = result[0].toPrecision(precision);\n\t\t}\n\n\t\tu = result[1] = STRINGS.symbol[standard][bits ? BITS : BYTES][e];\n\t} else {\n\t\tlet d = base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e);\n\t\tval = num / d;\n\n\t\tif (bits) {\n\t\t\tval = val * 8;\n\n\t\t\tif (val >= ceil && e < 8) {\n\t\t\t\tval = val / ceil;\n\t\t\t\te++;\n\t\t\t}\n\t\t}\n\n\t\tlet p = Math.pow(10, e > 0 ? round : 0);\n\t\tresult[0] = roundingFunc(val * p) / p;\n\n\t\tif (result[0] === ceil && e < 8 && exponent === -1) {\n\t\t\tresult[0] = 1;\n\t\t\te++;\n\t\t}\n\n\t\t// Setting optional precision\n\t\tif (precision > 0) {\n\t\t\tresult[0] = result[0].toPrecision(precision);\n\n\t\t\tif (result[0].includes(E) && e < 8) {\n\t\t\t\te++;\n\t\t\t\td = base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e);\n\t\t\t\tval = num / d;\n\t\t\t\tresult[0] = roundingFunc(val * p) / p;\n\t\t\t}\n\t\t}\n\n\t\tu = result[1] = base === 10 && e === 1 ? bits ? SI_KBIT : SI_KBYTE : STRINGS.symbol[standard][bits ? BITS : BYTES][e];\n\t}\n\n\t// Decorating a 'diff'\n\tif (neg) {\n\t\tresult[0] = -result[0];\n\t}\n\n\t// Applying custom symbol\n\tresult[1] = symbols[result[1]] || result[1];\n\n\tif (locale === true) {\n\t\tresult[0] = result[0].toLocaleString();\n\t} else if (locale.length > 0) {\n\t\tresult[0] = result[0].toLocaleString(locale, localeOptions);\n\t} else if (separator.length > 0) {\n\t\tresult[0] = result[0].toString().replace(PERIOD, separator);\n\t}\n\n\tif (pad && round > 0) {\n\t\tconst i = result[0].toString(),\n\t\t\tx = separator || ((i.match(/(\\D)/g) || []).pop() || PERIOD),\n\t\t\ttmp = i.toString().split(x),\n\t\t\ts = tmp[1] || EMPTY,\n\t\t\tl = s.length,\n\t\t\tn = round - l;\n\n\t\tresult[0] = `${tmp[0]}${x}${s.padEnd(l + n, ZERO)}`;\n\t}\n\n\tif (full) {\n\t\tresult[1] = fullforms[e] ? fullforms[e] : STRINGS.fullform[standard][e] + (bits ? BIT : BYTE) + (result[0] === 1 ? EMPTY : S);\n\t}\n\n\t// Returning Array, Object, or String (default)\n\treturn output === ARRAY ? result : output === OBJECT ? {\n\t\tvalue: result[0],\n\t\tsymbol: result[1],\n\t\texponent: e,\n\t\tunit: u\n\t} : result.join(spacer);\n}\n\n/**\n * Creates a partially applied version of filesize with preset options\n * @param {Object} [options={}] - Default options to apply to the returned function\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.0 KiB\"\n * formatBytes(2048) // \"2.0 KiB\"\n */\n// Partial application for functional programming\nexport function partial ({\n\tbits = false,\n\tpad = false,\n\tbase = -1,\n\tround = 2,\n\tlocale = EMPTY,\n\tlocaleOptions = {},\n\tseparator = EMPTY,\n\tspacer = SPACE,\n\tsymbols = {},\n\tstandard = EMPTY,\n\toutput = STRING,\n\tfullform = false,\n\tfullforms = [],\n\texponent = -1,\n\troundingMethod = ROUND,\n\tprecision = 0\n} = {}) {\n\treturn arg => filesize(arg, {\n\t\tbits,\n\t\tpad,\n\t\tbase,\n\t\tround,\n\t\tlocale,\n\t\tlocaleOptions,\n\t\tseparator,\n\t\tspacer,\n\t\tsymbols,\n\t\tstandard,\n\t\toutput,\n\t\tfullform,\n\t\tfullforms,\n\t\texponent,\n\t\troundingMethod,\n\t\tprecision\n\t});\n}\n"],"names":["JEDEC","BITS","BYTES","STRING","ROUND","EMPTY","STRINGS","symbol","iec","bits","bytes","jedec","fullform","filesize","arg","pad","base","round","locale","localeOptions","separator","spacer","symbols","standard","output","fullforms","exponent","roundingMethod","precision","e","num","Number","result","val","u","ceil","full","neg","roundingFunc","Math","isNaN","TypeError","floor","log","toPrecision","d","pow","p","includes","toLocaleString","length","toString","replace","i","x","match","pop","tmp","split","s","l","n","padEnd","value","unit","join","partial"],"mappings":";;;;AACO,MAKMA,EAAQ,QAKRC,EAAO,OAEPC,EAAQ,QAQRC,EAAS,SAITC,EAAQ,QAIRC,EAAQ,GAORC,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,WCK/D,SAASE,EAAUC,GAAKL,KAC9BA,GAAO,EAAKM,IACZA,GAAM,EAAKC,KACXA,GAAO,EAAEC,MACTA,EAAQ,EAACC,OACTA,EAASb,GAAKc,cACdA,EAAgB,CAAA,EAAEC,UAClBA,EAAYf,GAAKgB,OACjBA,ED9BoB,IC8BNC,QACdA,EAAU,C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SAASW,GAAUM,IAAMpB,EDlM1D,MAEC,SCgM6F,IAAduB,EAAO,GAAW3B,ED7KpG,MAbI,UC8LbmB,EAAmBQ,ED5LL,WC4LcR,EAAoB,CACtDuC,MAAO/B,EAAO,GACdzB,OAAQyB,EAAO,GACfN,SAAUG,EACVmC,KAAM9B,GACHF,EAAOiC,KAAK5C,EACjB,CA4BO,SAAS6C,GAASzD,KACxBA,GAAO,EAAKM,IACZA,GAAM,EAAKC,KACXA,GAAO,EAAEC,MACTA,EAAQ,EAACC,OACTA,EAASb,GAAKc,cACdA,EAAgB,CAAA,EAAEC,UAClBA,EAAYf,GAAKgB,OACjBA,ED1NoB,IC0NNC,QACdA,EAAU,CAAA,EAAEC,SACZA,EAAWlB,GAAKmB,OAChBA,EAASrB,EAAMS,SACfA,GAAW,EAAKa,UAChBA,EAAY,GAAEC,SACdA,GAAW,EAAEC,eACbA,EAAiBvB,EAAKwB,UACtBA,EAAY,GACT,IACH,OAAOd,GAAOD,EAASC,EAAK,CAC3BL,OACAM,MACAC,OACAC,QACAC,SACAC,gBACAC,YACAC,SACAC,UACAC,WACAC,SACAZ,WACAa,YACAC,WACAC,iBACAC,aAEF,QAAAf,cAAAqD"} \ No newline at end of file diff --git a/dist/filesize.umd.js b/dist/filesize.umd.js index 27c6743..0eaf553 100644 --- a/dist/filesize.umd.js +++ b/dist/filesize.umd.js @@ -194,7 +194,7 @@ function filesize (arg, { if (precision > 0) { result[0] = result[0].toPrecision(precision); - if (result[0].includes(E)) { + if (result[0].includes(E) && e < 8) { e++; d = base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e); val = num / d; diff --git a/dist/filesize.umd.min.js b/dist/filesize.umd.min.js index c0bc395..fd0a87f 100644 --- a/dist/filesize.umd.min.js +++ b/dist/filesize.umd.min.js @@ -2,4 +2,4 @@ 2025 Jason Mulligan @version 11.0.6 */ -!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).filesize={})}(this,function(t){"use strict";const i="jedec",e="bits",o="bytes",n="string",r="round",s="",l={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"]}};function a(t,{bits:a=!1,pad:b=!1,base:p=-1,round:f=2,locale:u="",localeOptions:c={},separator:d="",spacer:g=" ",symbols:m={},standard:h="",output:y=n,fullform:B=!1,fullforms:M=[],exponent:x=-1,roundingMethod:w=r,precision:T=0}={}){let E=x,j=Number(t),P=[],N=0,S=s;"si"===h?(p=10,h=i):"iec"===h||h===i?p=2:2===p?h="iec":(p=10,h=i);const k=10===p?1e3:1024,z=!0===B,G=j<0,K=Math[w];if("bigint"!=typeof t&&isNaN(t))throw new TypeError("Invalid number");if("function"!=typeof K)throw new TypeError("Invalid rounding method");if(G&&(j=-j),(-1===E||isNaN(E))&&(E=Math.floor(Math.log(j)/Math.log(k)),E<0&&(E=0)),E>8&&(T>0&&(T+=8-E),E=8),"exponent"===y)return E;if(0===j)P[0]=0,T>0&&(P[0]=P[0].toPrecision(T)),S=P[1]=l.symbol[h][a?e:o][E];else{let t=2===p?Math.pow(2,10*E):Math.pow(1e3,E);N=j/t,a&&(N*=8,N>=k&&E<8&&(N/=k,E++));let i=Math.pow(10,E>0?f:0);P[0]=K(N*i)/i,P[0]===k&&E<8&&-1===x&&(P[0]=1,E++),T>0&&(P[0]=P[0].toPrecision(T),P[0].includes("e")&&(E++,t=2===p?Math.pow(2,10*E):Math.pow(1e3,E),N=j/t,P[0]=K(N*i)/i)),S=P[1]=10===p&&1===E?a?"kbit":"kB":l.symbol[h][a?e:o][E]}if(G&&(P[0]=-P[0]),P[1]=m[P[1]]||P[1],!0===u?P[0]=P[0].toLocaleString():u.length>0?P[0]=P[0].toLocaleString(u,c):d.length>0&&(P[0]=P[0].toString().replace(".",d)),b&&f>0){const t=P[0].toString(),i=d||(t.match(/(\D)/g)||[]).pop()||".",e=t.toString().split(i),o=e[1]||s,n=o.length,r=f-n;P[0]=`${e[0]}${i}${o.padEnd(n+r,"0")}`}return z&&(P[1]=M[E]?M[E]:l.fullform[h][E]+(a?"bit":"byte")+(1===P[0]?s:"s")),"array"===y?P:"object"===y?{value:P[0],symbol:P[1],exponent:E,unit:S}:P.join(g)}t.filesize=a,t.partial=function({bits:t=!1,pad:i=!1,base:e=-1,round:o=2,locale:s="",localeOptions:l={},separator:b="",spacer:p=" ",symbols:f={},standard:u="",output:c=n,fullform:d=!1,fullforms:g=[],exponent:m=-1,roundingMethod:h=r,precision:y=0}={}){return n=>a(n,{bits:t,pad:i,base:e,round:o,locale:s,localeOptions:l,separator:b,spacer:p,symbols:f,standard:u,output:c,fullform:d,fullforms:g,exponent:m,roundingMethod:h,precision:y})}});//# sourceMappingURL=filesize.umd.min.js.map +!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).filesize={})}(this,function(t){"use strict";const i="jedec",e="bits",o="bytes",n="string",r="round",s="",l={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"]}};function a(t,{bits:a=!1,pad:b=!1,base:p=-1,round:f=2,locale:u="",localeOptions:c={},separator:d="",spacer:g=" ",symbols:m={},standard:h="",output:y=n,fullform:B=!1,fullforms:M=[],exponent:x=-1,roundingMethod:w=r,precision:T=0}={}){let E=x,j=Number(t),P=[],N=0,S=s;"si"===h?(p=10,h=i):"iec"===h||h===i?p=2:2===p?h="iec":(p=10,h=i);const k=10===p?1e3:1024,z=!0===B,G=j<0,K=Math[w];if("bigint"!=typeof t&&isNaN(t))throw new TypeError("Invalid number");if("function"!=typeof K)throw new TypeError("Invalid rounding method");if(G&&(j=-j),(-1===E||isNaN(E))&&(E=Math.floor(Math.log(j)/Math.log(k)),E<0&&(E=0)),E>8&&(T>0&&(T+=8-E),E=8),"exponent"===y)return E;if(0===j)P[0]=0,T>0&&(P[0]=P[0].toPrecision(T)),S=P[1]=l.symbol[h][a?e:o][E];else{let t=2===p?Math.pow(2,10*E):Math.pow(1e3,E);N=j/t,a&&(N*=8,N>=k&&E<8&&(N/=k,E++));let i=Math.pow(10,E>0?f:0);P[0]=K(N*i)/i,P[0]===k&&E<8&&-1===x&&(P[0]=1,E++),T>0&&(P[0]=P[0].toPrecision(T),P[0].includes("e")&&E<8&&(E++,t=2===p?Math.pow(2,10*E):Math.pow(1e3,E),N=j/t,P[0]=K(N*i)/i)),S=P[1]=10===p&&1===E?a?"kbit":"kB":l.symbol[h][a?e:o][E]}if(G&&(P[0]=-P[0]),P[1]=m[P[1]]||P[1],!0===u?P[0]=P[0].toLocaleString():u.length>0?P[0]=P[0].toLocaleString(u,c):d.length>0&&(P[0]=P[0].toString().replace(".",d)),b&&f>0){const t=P[0].toString(),i=d||(t.match(/(\D)/g)||[]).pop()||".",e=t.toString().split(i),o=e[1]||s,n=o.length,r=f-n;P[0]=`${e[0]}${i}${o.padEnd(n+r,"0")}`}return z&&(P[1]=M[E]?M[E]:l.fullform[h][E]+(a?"bit":"byte")+(1===P[0]?s:"s")),"array"===y?P:"object"===y?{value:P[0],symbol:P[1],exponent:E,unit:S}:P.join(g)}t.filesize=a,t.partial=function({bits:t=!1,pad:i=!1,base:e=-1,round:o=2,locale:s="",localeOptions:l={},separator:b="",spacer:p=" ",symbols:f={},standard:u="",output:c=n,fullform:d=!1,fullforms:g=[],exponent:m=-1,roundingMethod:h=r,precision:y=0}={}){return n=>a(n,{bits:t,pad:i,base:e,round:o,locale:s,localeOptions:l,separator:b,spacer:p,symbols:f,standard:u,output:c,fullform:d,fullforms:g,exponent:m,roundingMethod:h,precision:y})}});//# sourceMappingURL=filesize.umd.min.js.map diff --git a/dist/filesize.umd.min.js.map b/dist/filesize.umd.min.js.map index 83d3a80..a76336a 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/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","import {\n\tARRAY,\n\tBIT,\n\tBITS,\n\tBYTE,\n\tBYTES,\n\tE,\n\tEMPTY,\n\tEXPONENT,\n\tFUNCTION,\n\tIEC,\n\tINVALID_NUMBER,\n\tINVALID_ROUND,\n\tJEDEC,\n\tOBJECT,\n\tPERIOD,\n\tROUND,\n\tS,\n\tSI,\n\tSI_KBIT,\n\tSI_KBYTE,\n\tSPACE,\n\tSTRING,\n\tSTRINGS,\n\tZERO\n} from \"./constants.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 KB\"\n * filesize(1024, {bits: true}) // \"8 Kb\"\n * filesize(1024, {output: \"object\"}) // {value: 1, symbol: \"KB\", exponent: 1, unit: \"KB\"}\n */\nexport function filesize (arg, {\n\tbits = false,\n\tpad = false,\n\tbase = -1,\n\tround = 2,\n\tlocale = EMPTY,\n\tlocaleOptions = {},\n\tseparator = EMPTY,\n\tspacer = SPACE,\n\tsymbols = {},\n\tstandard = EMPTY,\n\toutput = STRING,\n\tfullform = false,\n\tfullforms = [],\n\texponent = -1,\n\troundingMethod = ROUND,\n\tprecision = 0\n} = {}) {\n\tlet e = exponent,\n\t\tnum = Number(arg),\n\t\tresult = [],\n\t\tval = 0,\n\t\tu = EMPTY;\n\n\t// Sync base & standard\n\tif (standard === SI) {\n\t\tbase = 10;\n\t\tstandard = JEDEC;\n\t} else if (standard === IEC || standard === JEDEC) {\n\t\tbase = 2;\n\t} else if (base === 2) {\n\t\tstandard = IEC;\n\t} else {\n\t\tbase = 10;\n\t\tstandard = JEDEC;\n\t}\n\n\tconst ceil = base === 10 ? 1000 : 1024,\n\t\tfull = fullform === true,\n\t\tneg = num < 0,\n\t\troundingFunc = Math[roundingMethod];\n\n\tif (typeof arg !== \"bigint\" && isNaN(arg)) {\n\t\tthrow new TypeError(INVALID_NUMBER);\n\t}\n\n\tif (typeof roundingFunc !== FUNCTION) {\n\t\tthrow new TypeError(INVALID_ROUND);\n\t}\n\n\t// Flipping a negative number to determine the size\n\tif (neg) {\n\t\tnum = -num;\n\t}\n\n\t// Determining the exponent\n\tif (e === -1 || isNaN(e)) {\n\t\te = Math.floor(Math.log(num) / Math.log(ceil));\n\n\t\tif (e < 0) {\n\t\t\te = 0;\n\t\t}\n\t}\n\n\t// Exceeding supported length, time to reduce & multiply\n\tif (e > 8) {\n\t\tif (precision > 0) {\n\t\t\tprecision += 8 - e;\n\t\t}\n\n\t\te = 8;\n\t}\n\n\tif (output === EXPONENT) {\n\t\treturn e;\n\t}\n\n\t// Zero is now a special case because bytes divide by 1\n\tif (num === 0) {\n\t\tresult[0] = 0;\n\n\t\tif (precision > 0) {\n\t\t\tresult[0] = result[0].toPrecision(precision);\n\t\t}\n\n\t\tu = result[1] = STRINGS.symbol[standard][bits ? BITS : BYTES][e];\n\t} else {\n\t\tlet d = base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e);\n\t\tval = num / d;\n\n\t\tif (bits) {\n\t\t\tval = val * 8;\n\n\t\t\tif (val >= ceil && e < 8) {\n\t\t\t\tval = val / ceil;\n\t\t\t\te++;\n\t\t\t}\n\t\t}\n\n\t\tlet p = Math.pow(10, e > 0 ? round : 0);\n\t\tresult[0] = roundingFunc(val * p) / p;\n\n\t\tif (result[0] === ceil && e < 8 && exponent === -1) {\n\t\t\tresult[0] = 1;\n\t\t\te++;\n\t\t}\n\n\t\t// Setting optional precision\n\t\tif (precision > 0) {\n\t\t\tresult[0] = result[0].toPrecision(precision);\n\n\t\t\tif (result[0].includes(E)) {\n\t\t\t\te++;\n\t\t\t\td = base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e);\n\t\t\t\tval = num / d;\n\t\t\t\tresult[0] = roundingFunc(val * p) / p;\n\t\t\t}\n\t\t}\n\n\t\tu = result[1] = base === 10 && e === 1 ? bits ? SI_KBIT : SI_KBYTE : STRINGS.symbol[standard][bits ? BITS : BYTES][e];\n\t}\n\n\t// Decorating a 'diff'\n\tif (neg) {\n\t\tresult[0] = -result[0];\n\t}\n\n\t// Applying custom symbol\n\tresult[1] = symbols[result[1]] || result[1];\n\n\tif (locale === true) {\n\t\tresult[0] = result[0].toLocaleString();\n\t} else if (locale.length > 0) {\n\t\tresult[0] = result[0].toLocaleString(locale, localeOptions);\n\t} else if (separator.length > 0) {\n\t\tresult[0] = result[0].toString().replace(PERIOD, separator);\n\t}\n\n\tif (pad && round > 0) {\n\t\tconst i = result[0].toString(),\n\t\t\tx = separator || ((i.match(/(\\D)/g) || []).pop() || PERIOD),\n\t\t\ttmp = i.toString().split(x),\n\t\t\ts = tmp[1] || EMPTY,\n\t\t\tl = s.length,\n\t\t\tn = round - l;\n\n\t\tresult[0] = `${tmp[0]}${x}${s.padEnd(l + n, ZERO)}`;\n\t}\n\n\tif (full) {\n\t\tresult[1] = fullforms[e] ? fullforms[e] : STRINGS.fullform[standard][e] + (bits ? BIT : BYTE) + (result[0] === 1 ? EMPTY : S);\n\t}\n\n\t// Returning Array, Object, or String (default)\n\treturn output === ARRAY ? result : output === OBJECT ? {\n\t\tvalue: result[0],\n\t\tsymbol: result[1],\n\t\texponent: e,\n\t\tunit: u\n\t} : result.join(spacer);\n}\n\n/**\n * Creates a partially applied version of filesize with preset options\n * @param {Object} [options={}] - Default options to apply to the returned function\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.0 KiB\"\n * formatBytes(2048) // \"2.0 KiB\"\n */\n// Partial application for functional programming\nexport function partial ({\n\tbits = false,\n\tpad = false,\n\tbase = -1,\n\tround = 2,\n\tlocale = EMPTY,\n\tlocaleOptions = {},\n\tseparator = EMPTY,\n\tspacer = SPACE,\n\tsymbols = {},\n\tstandard = EMPTY,\n\toutput = STRING,\n\tfullform = false,\n\tfullforms = [],\n\texponent = -1,\n\troundingMethod = ROUND,\n\tprecision = 0\n} = {}) {\n\treturn arg => filesize(arg, {\n\t\tbits,\n\t\tpad,\n\t\tbase,\n\t\tround,\n\t\tlocale,\n\t\tlocaleOptions,\n\t\tseparator,\n\t\tspacer,\n\t\tsymbols,\n\t\tstandard,\n\t\toutput,\n\t\tfullform,\n\t\tfullforms,\n\t\texponent,\n\t\troundingMethod,\n\t\tprecision\n\t});\n}\n"],"names":["g","f","exports","module","define","amd","globalThis","self","filesize","this","JEDEC","BITS","BYTES","STRING","ROUND","EMPTY","STRINGS","symbol","iec","bits","bytes","jedec","fullform","arg","pad","base","round","locale","localeOptions","separator","spacer","symbols","standard","output","fullforms","exponent","roundingMethod","precision","e","num","Number","result","val","u","ceil","full","neg","roundingFunc","Math","isNaN","TypeError","floor","log","toPrecision","d","pow","p","includes","toLocaleString","length","toString","replace","i","x","match","pop","tmp","split","s","l","n","padEnd","value","unit","join","partial"],"mappings":";;;;CAAA,SAAAA,EAAAC,GAAA,iBAAAC,SAAA,oBAAAC,OAAAF,EAAAC,S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A,GAAO,EAAKK,IACZA,GAAM,EAAKC,KACXA,GAAO,EAAEC,MACTA,EAAQ,EAACC,OACTA,EAASZ,GAAKa,cACdA,EAAgB,CAAA,EAAEC,UAClBA,EAAYd,GAAKe,OACjBA,ED1NoB,IC0NNC,QACdA,EAAU,CAAA,EAAEC,SACZA,EAAWjB,GAAKkB,OAChBA,EAASpB,EAAMS,SACfA,GAAW,EAAKY,UAChBA,EAAY,GAAEC,SACdA,GAAW,EAAEC,eACbA,EAAiBtB,EAAKuB,UACtBA,EAAY,GACT,IACH,OAAOd,GAAOf,EAASe,EAAK,CAC3BJ,OACAK,MACAC,OACAC,QACAC,SACAC,gBACAC,YACAC,SACAC,UACAC,WACAC,SACAX,WACAY,YACAC,WACAC,iBACAC,aAEF,CAAA"} \ No newline at end of file +{"version":3,"file":"filesize.umd.min.js","sources":["../src/constants.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","import {\n\tARRAY,\n\tBIT,\n\tBITS,\n\tBYTE,\n\tBYTES,\n\tE,\n\tEMPTY,\n\tEXPONENT,\n\tFUNCTION,\n\tIEC,\n\tINVALID_NUMBER,\n\tINVALID_ROUND,\n\tJEDEC,\n\tOBJECT,\n\tPERIOD,\n\tROUND,\n\tS,\n\tSI,\n\tSI_KBIT,\n\tSI_KBYTE,\n\tSPACE,\n\tSTRING,\n\tSTRINGS,\n\tZERO\n} from \"./constants.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 KB\"\n * filesize(1024, {bits: true}) // \"8 Kb\"\n * filesize(1024, {output: \"object\"}) // {value: 1, symbol: \"KB\", exponent: 1, unit: \"KB\"}\n */\nexport function filesize (arg, {\n\tbits = false,\n\tpad = false,\n\tbase = -1,\n\tround = 2,\n\tlocale = EMPTY,\n\tlocaleOptions = {},\n\tseparator = EMPTY,\n\tspacer = SPACE,\n\tsymbols = {},\n\tstandard = EMPTY,\n\toutput = STRING,\n\tfullform = false,\n\tfullforms = [],\n\texponent = -1,\n\troundingMethod = ROUND,\n\tprecision = 0\n} = {}) {\n\tlet e = exponent,\n\t\tnum = Number(arg),\n\t\tresult = [],\n\t\tval = 0,\n\t\tu = EMPTY;\n\n\t// Sync base & standard\n\tif (standard === SI) {\n\t\tbase = 10;\n\t\tstandard = JEDEC;\n\t} else if (standard === IEC || standard === JEDEC) {\n\t\tbase = 2;\n\t} else if (base === 2) {\n\t\tstandard = IEC;\n\t} else {\n\t\tbase = 10;\n\t\tstandard = JEDEC;\n\t}\n\n\tconst ceil = base === 10 ? 1000 : 1024,\n\t\tfull = fullform === true,\n\t\tneg = num < 0,\n\t\troundingFunc = Math[roundingMethod];\n\n\tif (typeof arg !== \"bigint\" && isNaN(arg)) {\n\t\tthrow new TypeError(INVALID_NUMBER);\n\t}\n\n\tif (typeof roundingFunc !== FUNCTION) {\n\t\tthrow new TypeError(INVALID_ROUND);\n\t}\n\n\t// Flipping a negative number to determine the size\n\tif (neg) {\n\t\tnum = -num;\n\t}\n\n\t// Determining the exponent\n\tif (e === -1 || isNaN(e)) {\n\t\te = Math.floor(Math.log(num) / Math.log(ceil));\n\n\t\tif (e < 0) {\n\t\t\te = 0;\n\t\t}\n\t}\n\n\t// Exceeding supported length, time to reduce & multiply\n\tif (e > 8) {\n\t\tif (precision > 0) {\n\t\t\tprecision += 8 - e;\n\t\t}\n\n\t\te = 8;\n\t}\n\n\tif (output === EXPONENT) {\n\t\treturn e;\n\t}\n\n\t// Zero is now a special case because bytes divide by 1\n\tif (num === 0) {\n\t\tresult[0] = 0;\n\n\t\tif (precision > 0) {\n\t\t\tresult[0] = result[0].toPrecision(precision);\n\t\t}\n\n\t\tu = result[1] = STRINGS.symbol[standard][bits ? BITS : BYTES][e];\n\t} else {\n\t\tlet d = base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e);\n\t\tval = num / d;\n\n\t\tif (bits) {\n\t\t\tval = val * 8;\n\n\t\t\tif (val >= ceil && e < 8) {\n\t\t\t\tval = val / ceil;\n\t\t\t\te++;\n\t\t\t}\n\t\t}\n\n\t\tlet p = Math.pow(10, e > 0 ? round : 0);\n\t\tresult[0] = roundingFunc(val * p) / p;\n\n\t\tif (result[0] === ceil && e < 8 && exponent === -1) {\n\t\t\tresult[0] = 1;\n\t\t\te++;\n\t\t}\n\n\t\t// Setting optional precision\n\t\tif (precision > 0) {\n\t\t\tresult[0] = result[0].toPrecision(precision);\n\n\t\t\tif (result[0].includes(E) && e < 8) {\n\t\t\t\te++;\n\t\t\t\td = base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e);\n\t\t\t\tval = num / d;\n\t\t\t\tresult[0] = roundingFunc(val * p) / p;\n\t\t\t}\n\t\t}\n\n\t\tu = result[1] = base === 10 && e === 1 ? bits ? SI_KBIT : SI_KBYTE : STRINGS.symbol[standard][bits ? BITS : BYTES][e];\n\t}\n\n\t// Decorating a 'diff'\n\tif (neg) {\n\t\tresult[0] = -result[0];\n\t}\n\n\t// Applying custom symbol\n\tresult[1] = symbols[result[1]] || result[1];\n\n\tif (locale === true) {\n\t\tresult[0] = result[0].toLocaleString();\n\t} else if (locale.length > 0) {\n\t\tresult[0] = result[0].toLocaleString(locale, localeOptions);\n\t} else if (separator.length > 0) {\n\t\tresult[0] = result[0].toString().replace(PERIOD, separator);\n\t}\n\n\tif (pad && round > 0) {\n\t\tconst i = result[0].toString(),\n\t\t\tx = separator || ((i.match(/(\\D)/g) || []).pop() || PERIOD),\n\t\t\ttmp = i.toString().split(x),\n\t\t\ts = tmp[1] || EMPTY,\n\t\t\tl = s.length,\n\t\t\tn = round - l;\n\n\t\tresult[0] = `${tmp[0]}${x}${s.padEnd(l + n, ZERO)}`;\n\t}\n\n\tif (full) {\n\t\tresult[1] = fullforms[e] ? fullforms[e] : STRINGS.fullform[standard][e] + (bits ? BIT : BYTE) + (result[0] === 1 ? EMPTY : S);\n\t}\n\n\t// Returning Array, Object, or String (default)\n\treturn output === ARRAY ? result : output === OBJECT ? {\n\t\tvalue: result[0],\n\t\tsymbol: result[1],\n\t\texponent: e,\n\t\tunit: u\n\t} : result.join(spacer);\n}\n\n/**\n * Creates a partially applied version of filesize with preset options\n * @param {Object} [options={}] - Default options to apply to the returned function\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.0 KiB\"\n * formatBytes(2048) // \"2.0 KiB\"\n */\n// Partial application for functional programming\nexport function partial ({\n\tbits = false,\n\tpad = false,\n\tbase = -1,\n\tround = 2,\n\tlocale = EMPTY,\n\tlocaleOptions = {},\n\tseparator = EMPTY,\n\tspacer = SPACE,\n\tsymbols = {},\n\tstandard = EMPTY,\n\toutput = STRING,\n\tfullform = false,\n\tfullforms = [],\n\texponent = -1,\n\troundingMethod = ROUND,\n\tprecision = 0\n} = {}) {\n\treturn arg => filesize(arg, {\n\t\tbits,\n\t\tpad,\n\t\tbase,\n\t\tround,\n\t\tlocale,\n\t\tlocaleOptions,\n\t\tseparator,\n\t\tspacer,\n\t\tsymbols,\n\t\tstandard,\n\t\toutput,\n\t\tfullform,\n\t\tfullforms,\n\t\texponent,\n\t\troundingMethod,\n\t\tprecision\n\t});\n}\n"],"names":["g","f","exports","module","define","amd","globalThis","self","filesize","this","JEDEC","BITS","BYTES","STRING","ROUND","EMPTY","STRINGS","symbol","iec","bits","bytes","jedec","fullform","arg","pad","base","round","locale","localeOptions","separator","spacer","symbols","standard","output","fullforms","exponent","roundingMethod","precision","e","num","Number","result","val","u","ceil","full","neg","roundingFunc","Math","isNaN","TypeError","floor","log","toPrecision","d","pow","p","includes","toLocaleString","length","toString","replace","i","x","match","pop","tmp","split","s","l","n","padEnd","value","unit","join","partial"],"mappings":";;;;CAAA,SAAAA,EAAAC,GAAA,iBAAAC,SAAA,o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AAAN,EAAAyE,QApCO,UAAkBxD,KACxBA,GAAO,EAAKK,IACZA,GAAM,EAAKC,KACXA,GAAO,EAAEC,MACTA,EAAQ,EAACC,OACTA,EAASZ,GAAKa,cACdA,EAAgB,CAAA,EAAEC,UAClBA,EAAYd,GAAKe,OACjBA,ED1NoB,IC0NNC,QACdA,EAAU,CAAA,EAAEC,SACZA,EAAWjB,GAAKkB,OAChBA,EAASpB,EAAMS,SACfA,GAAW,EAAKY,UAChBA,EAAY,GAAEC,SACdA,GAAW,EAAEC,eACbA,EAAiBtB,EAAKuB,UACtBA,EAAY,GACT,IACH,OAAOd,GAAOf,EAASe,EAAK,CAC3BJ,OACAK,MACAC,OACAC,QACAC,SACAC,gBACAC,YACAC,SACAC,UACAC,WACAC,SACAX,WACAY,YACAC,WACAC,iBACAC,aAEF,CAAA"} \ No newline at end of file diff --git a/src/filesize.js b/src/filesize.js index 517cd28..b5e18c9 100644 --- a/src/filesize.js +++ b/src/filesize.js @@ -163,7 +163,7 @@ export function filesize (arg, { if (precision > 0) { result[0] = result[0].toPrecision(precision); - if (result[0].includes(E)) { + if (result[0].includes(E) && e < 8) { e++; d = base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e); val = num / d; diff --git a/tests/unit/filesize.test.js b/tests/unit/filesize.test.js index e457295..a963ceb 100644 --- a/tests/unit/filesize.test.js +++ b/tests/unit/filesize.test.js @@ -279,7 +279,7 @@ describe('filesize', () => { }); }); - it('should handle precision with base 2 when scientific notation is produced', () => { + it('should handle precision with base 2 when scientific notation is produced (regular number)', () => { // Test case that triggers base === 2 path in line 168 precision handling // We need a number that will produce scientific notation with toPrecision // and uses base 2 (IEC standard) @@ -292,7 +292,19 @@ describe('filesize', () => { assert(result.includes('TiB') || result.includes('PiB')); }); - it('should handle precision with base 10 when scientific notation is produced', () => { + it('should handle precision with base 2 when scientific notation is produced (BigInt)', () => { + // Test case that triggers base === 2 path in line 168 precision handling using BigInt + // This ensures both number types are tested for base 2 path + const testNumber = BigInt('999999999999999'); // Large BigInt that triggers scientific notation + const result = filesize(testNumber, { precision: 1, standard: 'iec' }); + assert(typeof result === 'string'); + assert(!result.includes('e')); + assert(!result.includes('E')); + // Should use IEC units (base 2) + assert(result.includes('TiB') || result.includes('PiB')); + }); + + it('should handle precision with base 10 when scientific notation is produced (regular number)', () => { // Test case that triggers base === 10 path in line 168 precision handling // We need a number that will produce scientific notation with toPrecision // and uses base 10 (SI/JEDEC standard) @@ -304,6 +316,61 @@ describe('filesize', () => { // Should use JEDEC units (base 10 logic) assert(result.includes('TB') || result.includes('PB')); }); + + it('should handle precision with base 10 when scientific notation is produced (BigInt)', () => { + // Test case that triggers base === 10 path in line 168 precision handling using BigInt + // This ensures both number types are tested for base 10 path + const testNumber = BigInt('999999999999999'); // Large BigInt that triggers scientific notation + const result = filesize(testNumber, { precision: 1, standard: 'jedec' }); + assert(typeof result === 'string'); + assert(!result.includes('e')); + assert(!result.includes('E')); + // Should use JEDEC units (base 10 logic) + assert(result.includes('TB') || result.includes('PB')); + }); + + it('should handle precision with YiB-level numbers where e >= 8 (regular number)', () => { + // Test case that covers line 166 when e >= 8 (YiB level) using regular number + // This triggers result[0].includes(E) but e < 8 is false, so increment logic is skipped + const yibNumber = Math.pow(1024, 8); // 1 YiB in bytes using regular number + const result = filesize(yibNumber, { precision: 1, standard: 'iec' }); + assert(typeof result === 'string'); + // For extremely large regular numbers, some scientific notation may be expected + assert(result.includes('YiB')); + }); + + it('should handle precision with YiB-level numbers where e >= 8 (BigInt)', () => { + // Test case that covers line 166 when e >= 8 (YiB level) using BigInt + // This triggers result[0].includes(E) but e < 8 is false, so increment logic is skipped + // YiB is at exponent 8, so we need a number large enough to reach this level + const yibNumber = BigInt(1024) ** BigInt(8); // 1 YiB in bytes using BigInt + const result = filesize(yibNumber, { precision: 1, standard: 'iec' }); + assert(typeof result === 'string'); + assert(!result.includes('e')); + assert(!result.includes('E')); + assert(result.includes('YiB')); + }); + + it('should handle precision with extremely large numbers that exceed YiB (regular number)', () => { + // Test case for numbers that are larger than YiB using regular number + // This ensures we test the e >= 8 condition thoroughly with regular numbers + const extremeNumber = Math.pow(1024, 8) * 1000; // 1000 YiB using regular number + const result = filesize(extremeNumber, { precision: 2, standard: 'iec' }); + assert(typeof result === 'string'); + // For extremely large regular numbers, some scientific notation may be expected + assert(result.includes('YiB')); + }); + + it('should handle precision with extremely large numbers that exceed YiB (BigInt)', () => { + // Test case for numbers that are larger than YiB using BigInt + // This ensures we test the e >= 8 condition thoroughly with BigInt + const extremeNumber = BigInt(1024) ** BigInt(8) * BigInt(1000); // 1000 YiB using BigInt + const result = filesize(extremeNumber, { precision: 2, standard: 'iec' }); + assert(typeof result === 'string'); + // For extremely large BigInt numbers, the result should still use YiB units + // Some scientific notation in the final result may be acceptable for such large numbers + assert(result.includes('YiB')); + }); }); describe('Edge cases', () => { From a382bfb5cc3c5c3bb4d06e1c8078fffa8f555fce Mon Sep 17 00:00:00 2001 From: Jason Mulligan Date: Fri, 19 Sep 2025 08:35:07 -0400 Subject: [PATCH 2/2] Version bump --- CHANGELOG.md | 7 +++++++ dist/filesize.cjs | 2 +- dist/filesize.js | 2 +- dist/filesize.min.js | 2 +- dist/filesize.umd.js | 2 +- dist/filesize.umd.min.js | 2 +- package.json | 2 +- 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea8cb26..ce7f153 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,16 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [11.0.7](https://github.com/avoidwork/filesize.js/compare/11.0.6...11.0.7) + +- Fixing the upper boundary of 'precision' [`#204`](https://github.com/avoidwork/filesize.js/pull/204) + #### [11.0.6](https://github.com/avoidwork/filesize.js/compare/11.0.5...11.0.6) +> 19 September 2025 + - Taking a mulligan on 'precision' [`#203`](https://github.com/avoidwork/filesize.js/pull/203) +- Version bump [`63abcfb`](https://github.com/avoidwork/filesize.js/commit/63abcfbff702b14594abecc8dfaf1cd2efc75103) #### [11.0.5](https://github.com/avoidwork/filesize.js/compare/11.0.4...11.0.5) diff --git a/dist/filesize.cjs b/dist/filesize.cjs index 5589339..2ac0249 100644 --- a/dist/filesize.cjs +++ b/dist/filesize.cjs @@ -3,7 +3,7 @@ * * @copyright 2025 Jason Mulligan * @license BSD-3-Clause - * @version 11.0.6 + * @version 11.0.7 */ 'use strict'; diff --git a/dist/filesize.js b/dist/filesize.js index 8cc8be6..e039042 100644 --- a/dist/filesize.js +++ b/dist/filesize.js @@ -3,7 +3,7 @@ * * @copyright 2025 Jason Mulligan * @license BSD-3-Clause - * @version 11.0.6 + * @version 11.0.7 */ // Error Messages const INVALID_NUMBER = "Invalid number"; diff --git a/dist/filesize.min.js b/dist/filesize.min.js index d2d22b0..a07655f 100644 --- a/dist/filesize.min.js +++ b/dist/filesize.min.js @@ -1,5 +1,5 @@ /*! 2025 Jason Mulligan - @version 11.0.6 + @version 11.0.7 */ const t="jedec",i="bits",e="bytes",o="string",n="round",r="",a={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"]}};function l(l,{bits:s=!1,pad:b=!1,base:p=-1,round:c=2,locale:u="",localeOptions:d={},separator:f="",spacer:g=" ",symbols:m={},standard:h="",output:B=o,fullform:y=!1,fullforms:M=[],exponent:w=-1,roundingMethod:x=n,precision:E=0}={}){let P=w,T=Number(l),j=[],N=0,S=r;"si"===h?(p=10,h=t):"iec"===h||h===t?p=2:2===p?h="iec":(p=10,h=t);const k=10===p?1e3:1024,G=!0===y,K=T<0,Y=Math[x];if("bigint"!=typeof l&&isNaN(l))throw new TypeError("Invalid number");if("function"!=typeof Y)throw new TypeError("Invalid rounding method");if(K&&(T=-T),(-1===P||isNaN(P))&&(P=Math.floor(Math.log(T)/Math.log(k)),P<0&&(P=0)),P>8&&(E>0&&(E+=8-P),P=8),"exponent"===B)return P;if(0===T)j[0]=0,E>0&&(j[0]=j[0].toPrecision(E)),S=j[1]=a.symbol[h][s?i:e][P];else{let t=2===p?Math.pow(2,10*P):Math.pow(1e3,P);N=T/t,s&&(N*=8,N>=k&&P<8&&(N/=k,P++));let o=Math.pow(10,P>0?c:0);j[0]=Y(N*o)/o,j[0]===k&&P<8&&-1===w&&(j[0]=1,P++),E>0&&(j[0]=j[0].toPrecision(E),j[0].includes("e")&&P<8&&(P++,t=2===p?Math.pow(2,10*P):Math.pow(1e3,P),N=T/t,j[0]=Y(N*o)/o)),S=j[1]=10===p&&1===P?s?"kbit":"kB":a.symbol[h][s?i:e][P]}if(K&&(j[0]=-j[0]),j[1]=m[j[1]]||j[1],!0===u?j[0]=j[0].toLocaleString():u.length>0?j[0]=j[0].toLocaleString(u,d):f.length>0&&(j[0]=j[0].toString().replace(".",f)),b&&c>0){const t=j[0].toString(),i=f||(t.match(/(\D)/g)||[]).pop()||".",e=t.toString().split(i),o=e[1]||r,n=o.length,a=c-n;j[0]=`${e[0]}${i}${o.padEnd(n+a,"0")}`}return G&&(j[1]=M[P]?M[P]:a.fullform[h][P]+(s?"bit":"byte")+(1===j[0]?r:"s")),"array"===B?j:"object"===B?{value:j[0],symbol:j[1],exponent:P,unit:S}:j.join(g)}function s({bits:t=!1,pad:i=!1,base:e=-1,round:r=2,locale:a="",localeOptions:s={},separator:b="",spacer:p=" ",symbols:c={},standard:u="",output:d=o,fullform:f=!1,fullforms:g=[],exponent:m=-1,roundingMethod:h=n,precision:B=0}={}){return o=>l(o,{bits:t,pad:i,base:e,round:r,locale:a,localeOptions:s,separator:b,spacer:p,symbols:c,standard:u,output:d,fullform:f,fullforms:g,exponent:m,roundingMethod:h,precision:B})}export{l as filesize,s as partial};//# sourceMappingURL=filesize.min.js.map diff --git a/dist/filesize.umd.js b/dist/filesize.umd.js index 0eaf553..ea9d74e 100644 --- a/dist/filesize.umd.js +++ b/dist/filesize.umd.js @@ -3,7 +3,7 @@ * * @copyright 2025 Jason Mulligan * @license BSD-3-Clause - * @version 11.0.6 + * @version 11.0.7 */ (function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports):typeof define==='function'&&define.amd?define(['exports'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.filesize={}));})(this,(function(exports){'use strict';// Error Messages const INVALID_NUMBER = "Invalid number"; diff --git a/dist/filesize.umd.min.js b/dist/filesize.umd.min.js index fd0a87f..7a433ce 100644 --- a/dist/filesize.umd.min.js +++ b/dist/filesize.umd.min.js @@ -1,5 +1,5 @@ /*! 2025 Jason Mulligan - @version 11.0.6 + @version 11.0.7 */ !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).filesize={})}(this,function(t){"use strict";const i="jedec",e="bits",o="bytes",n="string",r="round",s="",l={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"]}};function a(t,{bits:a=!1,pad:b=!1,base:p=-1,round:f=2,locale:u="",localeOptions:c={},separator:d="",spacer:g=" ",symbols:m={},standard:h="",output:y=n,fullform:B=!1,fullforms:M=[],exponent:x=-1,roundingMethod:w=r,precision:T=0}={}){let E=x,j=Number(t),P=[],N=0,S=s;"si"===h?(p=10,h=i):"iec"===h||h===i?p=2:2===p?h="iec":(p=10,h=i);const k=10===p?1e3:1024,z=!0===B,G=j<0,K=Math[w];if("bigint"!=typeof t&&isNaN(t))throw new TypeError("Invalid number");if("function"!=typeof K)throw new TypeError("Invalid rounding method");if(G&&(j=-j),(-1===E||isNaN(E))&&(E=Math.floor(Math.log(j)/Math.log(k)),E<0&&(E=0)),E>8&&(T>0&&(T+=8-E),E=8),"exponent"===y)return E;if(0===j)P[0]=0,T>0&&(P[0]=P[0].toPrecision(T)),S=P[1]=l.symbol[h][a?e:o][E];else{let t=2===p?Math.pow(2,10*E):Math.pow(1e3,E);N=j/t,a&&(N*=8,N>=k&&E<8&&(N/=k,E++));let i=Math.pow(10,E>0?f:0);P[0]=K(N*i)/i,P[0]===k&&E<8&&-1===x&&(P[0]=1,E++),T>0&&(P[0]=P[0].toPrecision(T),P[0].includes("e")&&E<8&&(E++,t=2===p?Math.pow(2,10*E):Math.pow(1e3,E),N=j/t,P[0]=K(N*i)/i)),S=P[1]=10===p&&1===E?a?"kbit":"kB":l.symbol[h][a?e:o][E]}if(G&&(P[0]=-P[0]),P[1]=m[P[1]]||P[1],!0===u?P[0]=P[0].toLocaleString():u.length>0?P[0]=P[0].toLocaleString(u,c):d.length>0&&(P[0]=P[0].toString().replace(".",d)),b&&f>0){const t=P[0].toString(),i=d||(t.match(/(\D)/g)||[]).pop()||".",e=t.toString().split(i),o=e[1]||s,n=o.length,r=f-n;P[0]=`${e[0]}${i}${o.padEnd(n+r,"0")}`}return z&&(P[1]=M[E]?M[E]:l.fullform[h][E]+(a?"bit":"byte")+(1===P[0]?s:"s")),"array"===y?P:"object"===y?{value:P[0],symbol:P[1],exponent:E,unit:S}:P.join(g)}t.filesize=a,t.partial=function({bits:t=!1,pad:i=!1,base:e=-1,round:o=2,locale:s="",localeOptions:l={},separator:b="",spacer:p=" ",symbols:f={},standard:u="",output:c=n,fullform:d=!1,fullforms:g=[],exponent:m=-1,roundingMethod:h=r,precision:y=0}={}){return n=>a(n,{bits:t,pad:i,base:e,round:o,locale:s,localeOptions:l,separator:b,spacer:p,symbols:f,standard:u,output:c,fullform:d,fullforms:g,exponent:m,roundingMethod:h,precision:y})}});//# sourceMappingURL=filesize.umd.min.js.map diff --git a/package.json b/package.json index 55c96c0..bd3c47f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "filesize", "description": "JavaScript library to generate a human readable String describing the file size", - "version": "11.0.6", + "version": "11.0.7", "homepage": "https://filesizejs.com", "author": "Jason Mulligan ", "repository": {