From a833bb50e3157aa4e78cb387be50fa08be7553af Mon Sep 17 00:00:00 2001 From: Jason Mulligan Date: Wed, 1 Jun 2022 20:04:06 -0400 Subject: [PATCH] Updating the signature to use destructuring, removing edge case assignments on invalid inputs (fail by design) --- lib/filesize.es6.js | 69 +++--- lib/filesize.es6.min.js | 4 +- lib/filesize.es6.min.js.map | 2 +- lib/filesize.esm.js | 69 +++--- lib/filesize.esm.min.js | 4 +- lib/filesize.esm.min.js.map | 2 +- lib/filesize.js | 122 +++++----- lib/filesize.min.js | 4 +- lib/filesize.min.js.map | 2 +- package-lock.json | 430 ++++++++++++++++-------------------- package.json | 4 +- src/filesize.js | 67 +++--- test/filesize_test.js | 3 +- 13 files changed, 357 insertions(+), 425 deletions(-) diff --git a/lib/filesize.es6.js b/lib/filesize.es6.js index bcd39b2..85abe15 100644 --- a/lib/filesize.es6.js +++ b/lib/filesize.es6.js @@ -3,7 +3,7 @@ * * @copyright 2022 Jason Mulligan * @license BSD-3-Clause - * @version 9.0.0 + * @version 9.0.1 */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -11,23 +11,26 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.filesize = factory()); })(this, (function () { 'use strict'; - const symbol = { - iec: { - bits: ["bit", "Kibit", "Mibit", "Gibit", "Tibit", "Pibit", "Eibit", "Zibit", "Yibit"], - bytes: ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] + const strings = { + 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"] + } }, - 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"] } }, - fullform = { - iec: ["", "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi", "yobi"], - jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"] - }, roundingFuncs = { + ceil: Math.ceil, floor: Math.floor, - ceil: Math.ceil + round: Math.round }; /** @@ -38,35 +41,21 @@ * @param {Object} descriptor [Optional] Flags * @return {String} Readable file size String */ - function filesize (arg, descriptor = {}) { - let result = [], + function filesize (arg, {bits = false, pad = false, base = 10, round = 2, locale = "", localeOptions = {}, separator = "", spacer = " ", symbols = {}, standard = "iec", output = "string", fullform = false, fullforms = [], exponent = -1, roundingMethod = "round", precision = 0} = {}) { + let e = exponent, + num = Number(arg), + result = [], val = 0, - e, base, bits, ceil, full, fullforms, locale, localeOptions, neg, num, output, pad, round, u, separator, spacer, standard, symbols, roundingFunc, precision; + u = ""; + const ceil = base === 10 ? 1000 : 1024, + full = fullform === true, + neg = num < 0, + roundingFunc = roundingFuncs[roundingMethod]; if (isNaN(arg)) { throw new TypeError("Invalid number"); } - bits = descriptor.bits === true; - pad = descriptor.pad === true; - base = descriptor.base || 10; - round = descriptor.round !== void 0 ? descriptor.round : 2; - locale = descriptor.locale !== void 0 ? descriptor.locale : ""; - localeOptions = descriptor.localeOptions || {}; - separator = descriptor.separator !== void 0 ? descriptor.separator : ""; - spacer = descriptor.spacer !== void 0 ? descriptor.spacer : " "; - symbols = descriptor.symbols || {}; - standard = descriptor.standard in symbol ? descriptor.standard : "iec"; - output = descriptor.output || "string"; - full = descriptor.fullform === true; - fullforms = descriptor.fullforms instanceof Array ? descriptor.fullforms : []; - e = descriptor.exponent !== void 0 ? descriptor.exponent : -1; - roundingFunc = roundingFuncs[descriptor.roundingMethod] || Math.round; - num = Number(arg); - neg = num < 0; - ceil = base > 2 ? 1000 : 1024; - precision = isNaN(descriptor.precision) === false ? parseInt(descriptor.precision, 10) : 0; - // Flipping a negative number to determine the size if (neg) { num = -num; @@ -97,7 +86,7 @@ // Zero is now a special case because bytes divide by 1 if (num === 0) { result[0] = 0; - u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e]; + u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e]; } else { val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e)); @@ -113,12 +102,12 @@ const p = Math.pow(10, e > 0 ? round : 0); result[0] = roundingFunc(val * p) / p; - if (result[0] === ceil && e < 8 && descriptor.exponent === void 0) { + if (result[0] === ceil && e < 8 && exponent === -1) { result[0] = 1; e++; } - u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e]; + u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e]; } // Decorating a 'diff' @@ -153,7 +142,7 @@ } if (full) { - result[1] = fullforms[e] ? fullforms[e] : fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s"); + result[1] = fullforms[e] ? fullforms[e] : strings.fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s"); } // Returning Array, Object, or String (default) diff --git a/lib/filesize.es6.min.js b/lib/filesize.es6.min.js index dfc053c..5b1674e 100644 --- a/lib/filesize.es6.min.js +++ b/lib/filesize.es6.min.js @@ -1,6 +1,6 @@ /*! 2022 Jason Mulligan - @version 9.0.0 + @version 9.0.1 */ -!function(i,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(i="undefined"!=typeof globalThis?globalThis:i||self).filesize=t()}(this,(function(){"use strict";const i={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"]}},t={iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]},e={floor:Math.floor,ceil:Math.ceil};function o(o,n={}){let r,a,b,s,l,d,p,c,f,u,g,B,h,y,M,m,x,v,N,T,E=[],j=0;if(isNaN(o))throw new TypeError("Invalid number");if(b=!0===n.bits,B=!0===n.pad,a=n.base||10,h=void 0!==n.round?n.round:2,p=void 0!==n.locale?n.locale:"",c=n.localeOptions||{},M=void 0!==n.separator?n.separator:"",m=void 0!==n.spacer?n.spacer:" ",v=n.symbols||{},x=n.standard in i?n.standard:"iec",g=n.output||"string",l=!0===n.fullform,d=n.fullforms instanceof Array?n.fullforms:[],r=void 0!==n.exponent?n.exponent:-1,N=e[n.roundingMethod]||Math.round,u=Number(o),f=u<0,s=a>2?1e3:1024,T=!1===isNaN(n.precision)?parseInt(n.precision,10):0,f&&(u=-u),(-1===r||isNaN(r))&&(r=Math.floor(Math.log(u)/Math.log(s)),r<0&&(r=0)),r>8&&(T>0&&(T+=8-r),r=8),"exponent"===g)return r;if(0===u)E[0]=0,y=E[1]=i[x][b?"bits":"bytes"][r];else{j=u/(2===a?Math.pow(2,10*r):Math.pow(1e3,r)),b&&(j*=8,j>=s&&r<8&&(j/=s,r++));const t=Math.pow(10,r>0?h:0);E[0]=N(j*t)/t,E[0]===s&&r<8&&void 0===n.exponent&&(E[0]=1,r++),y=E[1]=i[x][b?"bits":"bytes"][r]}if(f&&(E[0]=-E[0]),T>0&&(E[0]=E[0].toPrecision(T)),E[1]=v[E[1]]||E[1],!0===p?E[0]=E[0].toLocaleString():p.length>0?E[0]=E[0].toLocaleString(p,c):M.length>0&&(E[0]=E[0].toString().replace(".",M)),B&&!1===Number.isInteger(E[0])&&h>0){const i=M||".",t=E[0].toString().split(i),e=t[1]||"",o=e.length,n=h-o;E[0]=`${t[0]}${i}${e.padEnd(o+n,"0")}`}return l&&(E[1]=d[r]?d[r]:t[x][r]+(b?"bit":"byte")+(1===E[0]?"":"s")),"array"===g?E:"object"===g?{value:E[0],symbol:E[1],exponent:r,unit:y}:E.join(m)}return o.partial=i=>t=>o(t,i),o})); +!function(i,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(i="undefined"!=typeof globalThis?globalThis:i||self).filesize=t()}(this,(function(){"use strict";const i={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"]}},t={ceil:Math.ceil,floor:Math.floor,round:Math.round};function e(e,{bits:o=!1,pad:n=!1,base:b=10,round:l=2,locale:r="",localeOptions:s={},separator:a="",spacer:f=" ",symbols:u={},standard:c="iec",output:p="string",fullform:d=!1,fullforms:g=[],exponent:y=-1,roundingMethod:B="round",precision:h=0}={}){let m=y,M=Number(e),x=[],T=0,E="";const N=10===b?1e3:1024,j=!0===d,w=M<0,P=t[B];if(isNaN(e))throw new TypeError("Invalid number");if(w&&(M=-M),(-1===m||isNaN(m))&&(m=Math.floor(Math.log(M)/Math.log(N)),m<0&&(m=0)),m>8&&(h>0&&(h+=8-m),m=8),"exponent"===p)return m;if(0===M)x[0]=0,E=x[1]=i.symbol[c][o?"bits":"bytes"][m];else{T=M/(2===b?Math.pow(2,10*m):Math.pow(1e3,m)),o&&(T*=8,T>=N&&m<8&&(T/=N,m++));const t=Math.pow(10,m>0?l:0);x[0]=P(T*t)/t,x[0]===N&&m<8&&-1===y&&(x[0]=1,m++),E=x[1]=i.symbol[c][o?"bits":"bytes"][m]}if(w&&(x[0]=-x[0]),h>0&&(x[0]=x[0].toPrecision(h)),x[1]=u[x[1]]||x[1],!0===r?x[0]=x[0].toLocaleString():r.length>0?x[0]=x[0].toLocaleString(r,s):a.length>0&&(x[0]=x[0].toString().replace(".",a)),n&&!1===Number.isInteger(x[0])&&l>0){const i=a||".",t=x[0].toString().split(i),e=t[1]||"",o=e.length,n=l-o;x[0]=`${t[0]}${i}${e.padEnd(o+n,"0")}`}return j&&(x[1]=g[m]?g[m]:i.fullform[c][m]+(o?"bit":"byte")+(1===x[0]?"":"s")),"array"===p?x:"object"===p?{value:x[0],symbol:x[1],exponent:m,unit:E}:x.join(f)}return e.partial=i=>t=>e(t,i),e})); //# sourceMappingURL=filesize.es6.min.js.map diff --git a/lib/filesize.es6.min.js.map b/lib/filesize.es6.min.js.map index ec34546..3766247 100644 --- a/lib/filesize.es6.min.js.map +++ b/lib/filesize.es6.min.js.map @@ -1 +1 @@ -{"version":3,"file":"filesize.es6.min.js","sources":["../src/filesize.js"],"sourcesContent":["const symbol = {\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\troundingFuncs = {\n\t\tfloor: Math.floor,\n\t\tceil: Math.ceil\n\t};\n\n/**\n * filesize\n *\n * @method filesize\n * @param {Mixed} arg String, Int or Float to transform\n * @param {Object} descriptor [Optional] Flags\n * @return {String} Readable file size String\n */\nfunction filesize (arg, descriptor = {}) {\n\tlet result = [],\n\t\tval = 0,\n\t\te, base, bits, ceil, full, fullforms, locale, localeOptions, neg, num, output, pad, round, u, separator, spacer, standard, symbols, roundingFunc, precision;\n\n\tif (isNaN(arg)) {\n\t\tthrow new TypeError(\"Invalid number\");\n\t}\n\n\tbits = descriptor.bits === true;\n\tpad = descriptor.pad === true;\n\tbase = descriptor.base || 10;\n\tround = descriptor.round !== void 0 ? descriptor.round : 2;\n\tlocale = descriptor.locale !== void 0 ? descriptor.locale : \"\";\n\tlocaleOptions = descriptor.localeOptions || {};\n\tseparator = descriptor.separator !== void 0 ? descriptor.separator : \"\";\n\tspacer = descriptor.spacer !== void 0 ? descriptor.spacer : \" \";\n\tsymbols = descriptor.symbols || {};\n\tstandard = descriptor.standard in symbol ? descriptor.standard : \"iec\";\n\toutput = descriptor.output || \"string\";\n\tfull = descriptor.fullform === true;\n\tfullforms = descriptor.fullforms instanceof Array ? descriptor.fullforms : [];\n\te = descriptor.exponent !== void 0 ? descriptor.exponent : -1;\n\troundingFunc = roundingFuncs[descriptor.roundingMethod] || Math.round;\n\tnum = Number(arg);\n\tneg = num < 0;\n\tceil = base > 2 ? 1000 : 1024;\n\tprecision = isNaN(descriptor.precision) === false ? parseInt(descriptor.precision, 10) : 0;\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\t\tu = result[1] = symbol[standard][bits ? \"bits\" : \"bytes\"][e];\n\t} else {\n\t\tval = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));\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\tconst 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 && descriptor.exponent === void 0) {\n\t\t\tresult[0] = 1;\n\t\t\te++;\n\t\t}\n\n\t\tu = result[1] = 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// Setting optional precision\n\tif (precision > 0) {\n\t\tresult[0] = result[0].toPrecision(precision);\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(\".\", separator);\n\t}\n\n\tif (pad && Number.isInteger(result[0]) === false && round > 0) {\n\t\tconst x = separator || \".\",\n\t\t\ttmp = result[0].toString().split(x),\n\t\t\ts = tmp[1] || \"\",\n\t\t\tl = s.length,\n\t\t\tn = round - l;\n\n\t\tresult[0] = `${tmp[0]}${x}${s.padEnd(l + n, \"0\")}`;\n\t}\n\n\tif (full) {\n\t\tresult[1] = fullforms[e] ? fullforms[e] : fullform[standard][e] + (bits ? \"bit\" : \"byte\") + (result[0] === 1 ? \"\" : \"s\");\n\t}\n\n\t// Returning Array, Object, or String (default)\n\treturn output === \"array\" ? result : output === \"object\" ? {value: result[0], symbol: result[1], exponent: e, unit: u} : result.join(spacer);\n}\n\n// Partial application for functional programming\nfilesize.partial = opt => arg => filesize(arg, opt);\n\nexport default filesize;\n"],"names":["symbol","iec","bits","bytes","jedec","fullform","roundingFuncs","floor","Math","ceil","filesize","arg","descriptor","e","base","full","fullforms","locale","localeOptions","neg","num","output","pad","round","u","separator","spacer","standard","symbols","roundingFunc","precision","result","val","isNaN","TypeError","Array","exponent","roundingMethod","Number","parseInt","log","pow","p","toPrecision","toLocaleString","length","toString","replace","isInteger","x","tmp","split","s","l","n","padEnd","value","unit","join","partial","opt"],"mappings":";;;;yOAAA,MAAMA,EAAS,CACbC,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,EAAW,CACVJ,IAAK,CAAC,GAAI,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,QAClEG,MAAO,CAAC,GAAI,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,MAAO,QAAS,UAErEE,EAAgB,CACfC,MAAOC,KAAKD,MACZE,KAAMD,KAAKC,MAWb,SAASC,EAAUC,EAAKC,EAAa,IACpC,IAECC,EAAGC,EAAMZ,EAAMO,EAAMM,EAAMC,EAAWC,EAAQC,EAAeC,EAAKC,EAAKC,EAAQC,EAAKC,EAAOC,EAAGC,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EAAoB,WAAXV,EAAsB,CAACmC,MAAOzB,EAAO,GAAI/B,OAAQ+B,EAAO,GAAIK,SAAUvB,EAAG4C,KAAMjC,GAAKO,EAAO2B,KAAKhC,UAItIhB,EAASiD,QAAUC,GAAOjD,GAAOD,EAASC,EAAKiD"} \ No newline at end of file +{"version":3,"file":"filesize.es6.min.js","sources":["../src/filesize.js"],"sourcesContent":["const strings = {\r\n\t\tsymbol: {\r\n\t\t\tiec: {\r\n\t\t\t\tbits: [\"bit\", \"Kibit\", \"Mibit\", \"Gibit\", \"Tibit\", \"Pibit\", \"Eibit\", \"Zibit\", \"Yibit\"],\r\n\t\t\t\tbytes: [\"B\", \"KiB\", \"MiB\", \"GiB\", \"TiB\", \"PiB\", \"EiB\", \"ZiB\", \"YiB\"]\r\n\t\t\t},\r\n\t\t\tjedec: {\r\n\t\t\t\tbits: [\"bit\", \"Kbit\", \"Mbit\", \"Gbit\", \"Tbit\", \"Pbit\", \"Ebit\", \"Zbit\", \"Ybit\"],\r\n\t\t\t\tbytes: [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"]\r\n\t\t\t}\r\n\t\t},\r\n\t\tfullform: {\r\n\t\t\tiec: [\"\", \"kibi\", \"mebi\", \"gibi\", \"tebi\", \"pebi\", \"exbi\", \"zebi\", \"yobi\"],\r\n\t\t\tjedec: [\"\", \"kilo\", \"mega\", \"giga\", \"tera\", \"peta\", \"exa\", \"zetta\", \"yotta\"]\r\n\t\t}\r\n\t},\r\n\troundingFuncs = {\r\n\t\tceil: Math.ceil,\r\n\t\tfloor: Math.floor,\r\n\t\tround: Math.round\r\n\t};\r\n\r\n/**\r\n * filesize\r\n *\r\n * @method filesize\r\n * @param {Mixed} arg String, Int or Float to transform\r\n * @param {Object} descriptor [Optional] Flags\r\n * @return {String} Readable file size String\r\n */\r\nfunction filesize (arg, {bits = false, pad = false, base = 10, round = 2, locale = \"\", localeOptions = {}, separator = \"\", spacer = \" \", symbols = {}, standard = \"iec\", output = \"string\", fullform = false, fullforms = [], exponent = -1, roundingMethod = \"round\", precision = 0} = {}) {\r\n\tlet e = exponent,\r\n\t\tnum = Number(arg),\r\n\t\tresult = [],\r\n\t\tval = 0,\r\n\t\tu = \"\";\r\n\tconst ceil = base === 10 ? 1000 : 1024,\r\n\t\tfull = fullform === true,\r\n\t\tneg = num < 0,\r\n\t\troundingFunc = roundingFuncs[roundingMethod];\r\n\r\n\tif (isNaN(arg)) {\r\n\t\tthrow new TypeError(\"Invalid number\");\r\n\t}\r\n\r\n\t// Flipping a negative number to determine the size\r\n\tif (neg) {\r\n\t\tnum = -num;\r\n\t}\r\n\r\n\t// Determining the exponent\r\n\tif (e === -1 || isNaN(e)) {\r\n\t\te = Math.floor(Math.log(num) / Math.log(ceil));\r\n\r\n\t\tif (e < 0) {\r\n\t\t\te = 0;\r\n\t\t}\r\n\t}\r\n\r\n\t// Exceeding supported length, time to reduce & multiply\r\n\tif (e > 8) {\r\n\t\tif (precision > 0) {\r\n\t\t\tprecision += 8 - e;\r\n\t\t}\r\n\r\n\t\te = 8;\r\n\t}\r\n\r\n\tif (output === \"exponent\") {\r\n\t\treturn e;\r\n\t}\r\n\r\n\t// Zero is now a special case because bytes divide by 1\r\n\tif (num === 0) {\r\n\t\tresult[0] = 0;\r\n\t\tu = result[1] = strings.symbol[standard][bits ? \"bits\" : \"bytes\"][e];\r\n\t} else {\r\n\t\tval = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));\r\n\r\n\t\tif (bits) {\r\n\t\t\tval = val * 8;\r\n\r\n\t\t\tif (val >= ceil && e < 8) {\r\n\t\t\t\tval = val / ceil;\r\n\t\t\t\te++;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst p = Math.pow(10, e > 0 ? round : 0);\r\n\t\tresult[0] = roundingFunc(val * p) / p;\r\n\r\n\t\tif (result[0] === ceil && e < 8 && exponent === -1) {\r\n\t\t\tresult[0] = 1;\r\n\t\t\te++;\r\n\t\t}\r\n\r\n\t\tu = result[1] = strings.symbol[standard][bits ? \"bits\" : \"bytes\"][e];\r\n\t}\r\n\r\n\t// Decorating a 'diff'\r\n\tif (neg) {\r\n\t\tresult[0] = -result[0];\r\n\t}\r\n\r\n\t// Setting optional precision\r\n\tif (precision > 0) {\r\n\t\tresult[0] = result[0].toPrecision(precision);\r\n\t}\r\n\r\n\t// Applying custom symbol\r\n\tresult[1] = symbols[result[1]] || result[1];\r\n\r\n\tif (locale === true) {\r\n\t\tresult[0] = result[0].toLocaleString();\r\n\t} else if (locale.length > 0) {\r\n\t\tresult[0] = result[0].toLocaleString(locale, localeOptions);\r\n\t} else if (separator.length > 0) {\r\n\t\tresult[0] = result[0].toString().replace(\".\", separator);\r\n\t}\r\n\r\n\tif (pad && Number.isInteger(result[0]) === false && round > 0) {\r\n\t\tconst x = separator || \".\",\r\n\t\t\ttmp = result[0].toString().split(x),\r\n\t\t\ts = tmp[1] || \"\",\r\n\t\t\tl = s.length,\r\n\t\t\tn = round - l;\r\n\r\n\t\tresult[0] = `${tmp[0]}${x}${s.padEnd(l + n, \"0\")}`;\r\n\t}\r\n\r\n\tif (full) {\r\n\t\tresult[1] = fullforms[e] ? fullforms[e] : strings.fullform[standard][e] + (bits ? \"bit\" : \"byte\") + (result[0] === 1 ? \"\" : \"s\");\r\n\t}\r\n\r\n\t// Returning Array, Object, or String (default)\r\n\treturn output === \"array\" ? result : output === \"object\" ? {value: result[0], symbol: result[1], exponent: e, unit: u} : result.join(spacer);\r\n}\r\n\r\n// Partial application for functional programming\r\nfilesize.partial = opt => arg => filesize(arg, opt);\r\n\r\nexport default filesize;\r\n"],"names":["strings","symbol","iec","bits","bytes","jedec","fullform","roundingFuncs","ceil","Math","floor","round","filesize","arg","pad","base","locale","localeOptions","separator","spacer","symbols","standard","output","fullforms","exponent","roundingMethod","precision","e","num","Number","result","val","u","full","neg","roundingFunc","isNaN","TypeError","log","pow","p","toPrecision","toLocaleString","length","toString","replace","isInteger","x","tmp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AO,GAAGc,WAAWK,MAAMF,GACjCG,EAAIF,EAAI,IAAM,GACdG,EAAID,EAAEP,OACNS,EAAIzC,EAAQwC,EAEbrB,EAAO,GAAK,GAAGkB,EAAI,KAAKD,IAAIG,EAAEG,OAAOF,EAAIC,EAAG,OAQ7C,OALInB,IACHH,EAAO,GAAKP,EAAUI,GAAKJ,EAAUI,GAAK3B,EAAQM,SAASe,GAAUM,IAAMxB,EAAO,MAAQ,SAAyB,IAAd2B,EAAO,GAAW,GAAK,MAI3G,UAAXR,EAAqBQ,EAAoB,WAAXR,EAAsB,CAACgC,MAAOxB,EAAO,GAAI7B,OAAQ6B,EAAO,GAAIN,SAAUG,EAAG4B,KAAMvB,GAAKF,EAAO0B,KAAKrC,UAItIP,EAAS6C,QAAUC,GAAO7C,GAAOD,EAASC,EAAK6C"} \ No newline at end of file diff --git a/lib/filesize.esm.js b/lib/filesize.esm.js index 35f3e2a..297d98a 100644 --- a/lib/filesize.esm.js +++ b/lib/filesize.esm.js @@ -3,25 +3,28 @@ * * @copyright 2022 Jason Mulligan * @license BSD-3-Clause - * @version 9.0.0 + * @version 9.0.1 */ -const symbol = { - iec: { - bits: ["bit", "Kibit", "Mibit", "Gibit", "Tibit", "Pibit", "Eibit", "Zibit", "Yibit"], - bytes: ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] +const strings = { + 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"] + } }, - 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"] } }, - fullform = { - iec: ["", "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi", "yobi"], - jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"] - }, roundingFuncs = { + ceil: Math.ceil, floor: Math.floor, - ceil: Math.ceil + round: Math.round }; /** @@ -32,35 +35,21 @@ const symbol = { * @param {Object} descriptor [Optional] Flags * @return {String} Readable file size String */ -function filesize (arg, descriptor = {}) { - let result = [], +function filesize (arg, {bits = false, pad = false, base = 10, round = 2, locale = "", localeOptions = {}, separator = "", spacer = " ", symbols = {}, standard = "iec", output = "string", fullform = false, fullforms = [], exponent = -1, roundingMethod = "round", precision = 0} = {}) { + let e = exponent, + num = Number(arg), + result = [], val = 0, - e, base, bits, ceil, full, fullforms, locale, localeOptions, neg, num, output, pad, round, u, separator, spacer, standard, symbols, roundingFunc, precision; + u = ""; + const ceil = base === 10 ? 1000 : 1024, + full = fullform === true, + neg = num < 0, + roundingFunc = roundingFuncs[roundingMethod]; if (isNaN(arg)) { throw new TypeError("Invalid number"); } - bits = descriptor.bits === true; - pad = descriptor.pad === true; - base = descriptor.base || 10; - round = descriptor.round !== void 0 ? descriptor.round : 2; - locale = descriptor.locale !== void 0 ? descriptor.locale : ""; - localeOptions = descriptor.localeOptions || {}; - separator = descriptor.separator !== void 0 ? descriptor.separator : ""; - spacer = descriptor.spacer !== void 0 ? descriptor.spacer : " "; - symbols = descriptor.symbols || {}; - standard = descriptor.standard in symbol ? descriptor.standard : "iec"; - output = descriptor.output || "string"; - full = descriptor.fullform === true; - fullforms = descriptor.fullforms instanceof Array ? descriptor.fullforms : []; - e = descriptor.exponent !== void 0 ? descriptor.exponent : -1; - roundingFunc = roundingFuncs[descriptor.roundingMethod] || Math.round; - num = Number(arg); - neg = num < 0; - ceil = base > 2 ? 1000 : 1024; - precision = isNaN(descriptor.precision) === false ? parseInt(descriptor.precision, 10) : 0; - // Flipping a negative number to determine the size if (neg) { num = -num; @@ -91,7 +80,7 @@ function filesize (arg, descriptor = {}) { // Zero is now a special case because bytes divide by 1 if (num === 0) { result[0] = 0; - u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e]; + u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e]; } else { val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e)); @@ -107,12 +96,12 @@ function filesize (arg, descriptor = {}) { const p = Math.pow(10, e > 0 ? round : 0); result[0] = roundingFunc(val * p) / p; - if (result[0] === ceil && e < 8 && descriptor.exponent === void 0) { + if (result[0] === ceil && e < 8 && exponent === -1) { result[0] = 1; e++; } - u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e]; + u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e]; } // Decorating a 'diff' @@ -147,7 +136,7 @@ function filesize (arg, descriptor = {}) { } if (full) { - result[1] = fullforms[e] ? fullforms[e] : fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s"); + result[1] = fullforms[e] ? fullforms[e] : strings.fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s"); } // Returning Array, Object, or String (default) diff --git a/lib/filesize.esm.min.js b/lib/filesize.esm.min.js index 6fd1b5c..f2d49d1 100644 --- a/lib/filesize.esm.min.js +++ b/lib/filesize.esm.min.js @@ -1,6 +1,6 @@ /*! 2022 Jason Mulligan - @version 9.0.0 + @version 9.0.1 */ -const i={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"]}},t={iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]},e={floor:Math.floor,ceil:Math.ceil};function o(o,a={}){let n,r,b,s,l,p,c,d,u,B,f,g,h,M,y,m,v,x,N,E,w=[],P=0;if(isNaN(o))throw new TypeError("Invalid number");if(b=!0===a.bits,g=!0===a.pad,r=a.base||10,h=void 0!==a.round?a.round:2,c=void 0!==a.locale?a.locale:"",d=a.localeOptions||{},y=void 0!==a.separator?a.separator:"",m=void 0!==a.spacer?a.spacer:" ",x=a.symbols||{},v=a.standard in i?a.standard:"iec",f=a.output||"string",l=!0===a.fullform,p=a.fullforms instanceof Array?a.fullforms:[],n=void 0!==a.exponent?a.exponent:-1,N=e[a.roundingMethod]||Math.round,B=Number(o),u=B<0,s=r>2?1e3:1024,E=!1===isNaN(a.precision)?parseInt(a.precision,10):0,u&&(B=-B),(-1===n||isNaN(n))&&(n=Math.floor(Math.log(B)/Math.log(s)),n<0&&(n=0)),n>8&&(E>0&&(E+=8-n),n=8),"exponent"===f)return n;if(0===B)w[0]=0,M=w[1]=i[v][b?"bits":"bytes"][n];else{P=B/(2===r?Math.pow(2,10*n):Math.pow(1e3,n)),b&&(P*=8,P>=s&&n<8&&(P/=s,n++));const t=Math.pow(10,n>0?h:0);w[0]=N(P*t)/t,w[0]===s&&n<8&&void 0===a.exponent&&(w[0]=1,n++),M=w[1]=i[v][b?"bits":"bytes"][n]}if(u&&(w[0]=-w[0]),E>0&&(w[0]=w[0].toPrecision(E)),w[1]=x[w[1]]||w[1],!0===c?w[0]=w[0].toLocaleString():c.length>0?w[0]=w[0].toLocaleString(c,d):y.length>0&&(w[0]=w[0].toString().replace(".",y)),g&&!1===Number.isInteger(w[0])&&h>0){const i=y||".",t=w[0].toString().split(i),e=t[1]||"",o=e.length,a=h-o;w[0]=`${t[0]}${i}${e.padEnd(o+a,"0")}`}return l&&(w[1]=p[n]?p[n]:t[v][n]+(b?"bit":"byte")+(1===w[0]?"":"s")),"array"===f?w:"object"===f?{value:w[0],symbol:w[1],exponent:n,unit:M}:w.join(m)}o.partial=i=>t=>o(t,i);export{o as default}; +const t={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"]}},i={ceil:Math.ceil,floor:Math.floor,round:Math.round};function e(e,{bits:o=!1,pad:b=!1,base:r=10,round:a=2,locale:n="",localeOptions:l={},separator:s="",spacer:c=" ",symbols:p={},standard:u="iec",output:B="string",fullform:f=!1,fullforms:g=[],exponent:d=-1,roundingMethod:h="round",precision:m=0}={}){let y=d,M=Number(e),x=[],E=0,N="";const w=10===r?1e3:1024,P=!0===f,T=M<0,j=i[h];if(isNaN(e))throw new TypeError("Invalid number");if(T&&(M=-M),(-1===y||isNaN(y))&&(y=Math.floor(Math.log(M)/Math.log(w)),y<0&&(y=0)),y>8&&(m>0&&(m+=8-y),y=8),"exponent"===B)return y;if(0===M)x[0]=0,N=x[1]=t.symbol[u][o?"bits":"bytes"][y];else{E=M/(2===r?Math.pow(2,10*y):Math.pow(1e3,y)),o&&(E*=8,E>=w&&y<8&&(E/=w,y++));const i=Math.pow(10,y>0?a:0);x[0]=j(E*i)/i,x[0]===w&&y<8&&-1===d&&(x[0]=1,y++),N=x[1]=t.symbol[u][o?"bits":"bytes"][y]}if(T&&(x[0]=-x[0]),m>0&&(x[0]=x[0].toPrecision(m)),x[1]=p[x[1]]||x[1],!0===n?x[0]=x[0].toLocaleString():n.length>0?x[0]=x[0].toLocaleString(n,l):s.length>0&&(x[0]=x[0].toString().replace(".",s)),b&&!1===Number.isInteger(x[0])&&a>0){const t=s||".",i=x[0].toString().split(t),e=i[1]||"",o=e.length,b=a-o;x[0]=`${i[0]}${t}${e.padEnd(o+b,"0")}`}return P&&(x[1]=g[y]?g[y]:t.fullform[u][y]+(o?"bit":"byte")+(1===x[0]?"":"s")),"array"===B?x:"object"===B?{value:x[0],symbol:x[1],exponent:y,unit:N}:x.join(c)}e.partial=t=>i=>e(i,t);export{e as default}; //# sourceMappingURL=filesize.esm.min.js.map diff --git a/lib/filesize.esm.min.js.map b/lib/filesize.esm.min.js.map index bc52316..3fdbfea 100644 --- a/lib/filesize.esm.min.js.map +++ b/lib/filesize.esm.min.js.map @@ -1 +1 @@ -{"version":3,"file":"filesize.esm.min.js","sources":["../src/filesize.js"],"sourcesContent":["const symbol = {\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\troundingFuncs = {\n\t\tfloor: Math.floor,\n\t\tceil: Math.ceil\n\t};\n\n/**\n * filesize\n *\n * @method filesize\n * @param {Mixed} arg String, Int or Float to transform\n * @param {Object} descriptor [Optional] Flags\n * @return {String} Readable file size String\n */\nfunction filesize (arg, descriptor = {}) {\n\tlet result = [],\n\t\tval = 0,\n\t\te, base, bits, ceil, full, fullforms, locale, localeOptions, neg, num, output, pad, round, u, separator, spacer, standard, symbols, roundingFunc, precision;\n\n\tif (isNaN(arg)) {\n\t\tthrow new TypeError(\"Invalid number\");\n\t}\n\n\tbits = descriptor.bits === true;\n\tpad = descriptor.pad === true;\n\tbase = descriptor.base || 10;\n\tround = descriptor.round !== void 0 ? descriptor.round : 2;\n\tlocale = descriptor.locale !== void 0 ? descriptor.locale : \"\";\n\tlocaleOptions = descriptor.localeOptions || {};\n\tseparator = descriptor.separator !== void 0 ? descriptor.separator : \"\";\n\tspacer = descriptor.spacer !== void 0 ? descriptor.spacer : \" \";\n\tsymbols = descriptor.symbols || {};\n\tstandard = descriptor.standard in symbol ? descriptor.standard : \"iec\";\n\toutput = descriptor.output || \"string\";\n\tfull = descriptor.fullform === true;\n\tfullforms = descriptor.fullforms instanceof Array ? descriptor.fullforms : [];\n\te = descriptor.exponent !== void 0 ? descriptor.exponent : -1;\n\troundingFunc = roundingFuncs[descriptor.roundingMethod] || Math.round;\n\tnum = Number(arg);\n\tneg = num < 0;\n\tceil = base > 2 ? 1000 : 1024;\n\tprecision = isNaN(descriptor.precision) === false ? parseInt(descriptor.precision, 10) : 0;\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\t\tu = result[1] = symbol[standard][bits ? \"bits\" : \"bytes\"][e];\n\t} else {\n\t\tval = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));\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\tconst 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 && descriptor.exponent === void 0) {\n\t\t\tresult[0] = 1;\n\t\t\te++;\n\t\t}\n\n\t\tu = result[1] = 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// Setting optional precision\n\tif (precision > 0) {\n\t\tresult[0] = result[0].toPrecision(precision);\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(\".\", separator);\n\t}\n\n\tif (pad && Number.isInteger(result[0]) === false && round > 0) {\n\t\tconst x = separator || \".\",\n\t\t\ttmp = result[0].toString().split(x),\n\t\t\ts = tmp[1] || \"\",\n\t\t\tl = s.length,\n\t\t\tn = round - l;\n\n\t\tresult[0] = `${tmp[0]}${x}${s.padEnd(l + n, \"0\")}`;\n\t}\n\n\tif (full) {\n\t\tresult[1] = fullforms[e] ? fullforms[e] : fullform[standard][e] + (bits ? \"bit\" : \"byte\") + (result[0] === 1 ? \"\" : \"s\");\n\t}\n\n\t// Returning Array, Object, or String (default)\n\treturn output === \"array\" ? result : output === \"object\" ? {value: result[0], symbol: result[1], exponent: e, unit: u} : result.join(spacer);\n}\n\n// Partial application for functional programming\nfilesize.partial = opt => arg => filesize(arg, opt);\n\nexport default filesize;\n"],"names":["symbol","iec","bits","bytes","jedec","fullform","roundingFuncs","floor","Math","ceil","filesize","arg","descriptor","e","base","full","fullforms","locale","localeOptions","neg","num","output","pad","round","u","separator","spacer","standard","symbols","roundingFunc","precision","result","val","isNaN","TypeError","Array","exponent","roundingMethod","Number","parseInt","log","pow","p","toPrecision","toLocaleString","length","toString","replace","isInteger","x","tmp","split","s","l","n","padEnd","value","unit","join","partial","opt"],"mappings":";;;;AAAA,MAAMA,EAAS,CACbC,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,EAAW,CACVJ,IAAK,CAAC,GAAI,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,QAClEG,MAAO,CAAC,GAAI,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,MAAO,QAAS,UAErEE,EAAgB,CACfC,MAAOC,KAAKD,MACZE,KAAMD,KAAKC,MAWb,SAASC,EAAUC,EAAKC,EAAa,IACpC,IAECC,EAAGC,EAAMZ,EAAMO,EAAMM,EAAMC,EAAWC,EAAQC,EAAeC,EAAKC,EAAKC,EAAQC,EAAKC,EAAOC,EAAGC,EAAWC,EAAQC,EAAUC,EAASC,EAAcC,EAF/IC,EAAS,GACZC,EAAM,EAGP,GAAIC,MAAMtB,GACT,MAAM,IAAIuB,UAAU,kBA8CrB,GA3CAhC,GAA2B,IAApBU,EAAWV,KAClBoB,GAAyB,IAAnBV,EAAWU,IACjBR,EAAOF,EAAWE,MAAQ,GAC1BS,OAA6B,IAArBX,E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sourcesContent":["const strings = {\r\n\t\tsymbol: {\r\n\t\t\tiec: {\r\n\t\t\t\tbits: [\"bit\", \"Kibit\", \"Mibit\", \"Gibit\", \"Tibit\", \"Pibit\", \"Eibit\", \"Zibit\", \"Yibit\"],\r\n\t\t\t\tbytes: [\"B\", \"KiB\", \"MiB\", \"GiB\", \"TiB\", \"PiB\", \"EiB\", \"ZiB\", \"YiB\"]\r\n\t\t\t},\r\n\t\t\tjedec: {\r\n\t\t\t\tbits: [\"bit\", \"Kbit\", \"Mbit\", \"Gbit\", \"Tbit\", \"Pbit\", \"Ebit\", \"Zbit\", \"Ybit\"],\r\n\t\t\t\tbytes: [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"]\r\n\t\t\t}\r\n\t\t},\r\n\t\tfullform: {\r\n\t\t\tiec: [\"\", \"kibi\", \"mebi\", \"gibi\", \"tebi\", \"pebi\", \"exbi\", \"zebi\", \"yobi\"],\r\n\t\t\tjedec: [\"\", \"kilo\", \"mega\", \"giga\", \"tera\", \"peta\", \"exa\", \"zetta\", \"yotta\"]\r\n\t\t}\r\n\t},\r\n\troundingFuncs = {\r\n\t\tceil: Math.ceil,\r\n\t\tfloor: Math.floor,\r\n\t\tround: Math.round\r\n\t};\r\n\r\n/**\r\n * filesize\r\n *\r\n * @method filesize\r\n * @param {Mixed} arg String, Int or Float to transform\r\n * @param {Object} descriptor [Optional] Flags\r\n * @return {String} Readable file size String\r\n */\r\nfunction filesize (arg, {bits = false, pad = false, base = 10, round = 2, locale = \"\", localeOptions = {}, separator = \"\", spacer = \" \", symbols = {}, standard = \"iec\", output = \"string\", fullform = false, fullforms = [], exponent = -1, roundingMethod = \"round\", precision = 0} = {}) {\r\n\tlet e = exponent,\r\n\t\tnum = Number(arg),\r\n\t\tresult = [],\r\n\t\tval = 0,\r\n\t\tu = \"\";\r\n\tconst ceil = base === 10 ? 1000 : 1024,\r\n\t\tfull = fullform === true,\r\n\t\tneg = num < 0,\r\n\t\troundingFunc = roundingFuncs[roundingMethod];\r\n\r\n\tif (isNaN(arg)) {\r\n\t\tthrow new TypeError(\"Invalid number\");\r\n\t}\r\n\r\n\t// Flipping a negative number to determine the size\r\n\tif (neg) {\r\n\t\tnum = -num;\r\n\t}\r\n\r\n\t// Determining the exponent\r\n\tif (e === -1 || isNaN(e)) {\r\n\t\te = Math.floor(Math.log(num) / Math.log(ceil));\r\n\r\n\t\tif (e < 0) {\r\n\t\t\te = 0;\r\n\t\t}\r\n\t}\r\n\r\n\t// Exceeding supported length, time to reduce & multiply\r\n\tif (e > 8) {\r\n\t\tif (precision > 0) {\r\n\t\t\tprecision += 8 - e;\r\n\t\t}\r\n\r\n\t\te = 8;\r\n\t}\r\n\r\n\tif (output === \"exponent\") {\r\n\t\treturn e;\r\n\t}\r\n\r\n\t// Zero is now a special case because bytes divide by 1\r\n\tif (num === 0) {\r\n\t\tresult[0] = 0;\r\n\t\tu = result[1] = strings.symbol[standard][bits ? \"bits\" : \"bytes\"][e];\r\n\t} else {\r\n\t\tval = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));\r\n\r\n\t\tif (bits) {\r\n\t\t\tval = val * 8;\r\n\r\n\t\t\tif (val >= ceil && e < 8) {\r\n\t\t\t\tval = val / ceil;\r\n\t\t\t\te++;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst p = Math.pow(10, e > 0 ? round : 0);\r\n\t\tresult[0] = roundingFunc(val * p) / p;\r\n\r\n\t\tif (result[0] === ceil && e < 8 && exponent === -1) {\r\n\t\t\tresult[0] = 1;\r\n\t\t\te++;\r\n\t\t}\r\n\r\n\t\tu = result[1] = strings.symbol[standard][bits ? \"bits\" : \"bytes\"][e];\r\n\t}\r\n\r\n\t// Decorating a 'diff'\r\n\tif (neg) {\r\n\t\tresult[0] = -result[0];\r\n\t}\r\n\r\n\t// Setting optional precision\r\n\tif (precision > 0) {\r\n\t\tresult[0] = result[0].toPrecision(precision);\r\n\t}\r\n\r\n\t// Applying custom symbol\r\n\tresult[1] = symbols[result[1]] || result[1];\r\n\r\n\tif (locale === true) {\r\n\t\tresult[0] = result[0].toLocaleString();\r\n\t} else if (locale.length > 0) {\r\n\t\tresult[0] = result[0].toLocaleString(locale, localeOptions);\r\n\t} else if (separator.length > 0) {\r\n\t\tresult[0] = result[0].toString().replace(\".\", separator);\r\n\t}\r\n\r\n\tif (pad && Number.isInteger(result[0]) === false && round > 0) {\r\n\t\tconst x = separator || \".\",\r\n\t\t\ttmp = result[0].toString().split(x),\r\n\t\t\ts = tmp[1] || \"\",\r\n\t\t\tl = s.length,\r\n\t\t\tn = round - l;\r\n\r\n\t\tresult[0] = `${tmp[0]}${x}${s.padEnd(l + n, \"0\")}`;\r\n\t}\r\n\r\n\tif (full) {\r\n\t\tresult[1] = fullforms[e] ? fullforms[e] : strings.fullform[standard][e] + (bits ? \"bit\" : \"byte\") + (result[0] === 1 ? \"\" : \"s\");\r\n\t}\r\n\r\n\t// Returning Array, Object, or String (default)\r\n\treturn output === \"array\" ? result : output === \"object\" ? {value: result[0], symbol: result[1], exponent: e, unit: u} : result.join(spacer);\r\n}\r\n\r\n// Partial application for functional programming\r\nfilesize.partial = opt => arg => filesize(arg, opt);\r\n\r\nexport default filesize;\r\n"],"names":["strings","symbol","iec","bits","bytes","jedec","fullform","roundingFuncs","ceil","Math","floor","round","filesize","arg","pad","base","locale","localeOptions","separator","spacer","symbols","standard","output","fullforms","exponent","roundingMethod","precision","e","num","Number","result","val","u","full","neg","roundingFunc","isNaN","TypeError","log","pow","p","toPrecision","toLocaleString","length","toString","replace","isInteger","x","tmp","split","s","l","n","padEnd","value","unit","join","partial","opt"],"mappings":";;;;AAAA,MAAMA,EAAU,CACdC,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,M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,EAAQM,SAASe,GAAUM,IAAMxB,EAAO,MAAQ,SAAyB,IAAd2B,EAAO,GAAW,GAAK,MAI3G,UAAXR,EAAqBQ,EAAoB,WAAXR,EAAsB,CAACgC,MAAOxB,EAAO,GAAI7B,OAAQ6B,EAAO,GAAIN,SAAUG,EAAG4B,KAAMvB,GAAKF,EAAO0B,KAAKrC,GAItIP,EAAS6C,QAAUC,GAAO7C,GAAOD,EAASC,EAAK6C"} \ No newline at end of file diff --git a/lib/filesize.js b/lib/filesize.js index 48cd38f..1ecbfc5 100644 --- a/lib/filesize.js +++ b/lib/filesize.js @@ -3,7 +3,7 @@ * * @copyright 2022 Jason Mulligan * @license BSD-3-Clause - * @version 9.0.0 + * @version 9.0.1 */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -11,23 +11,26 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.filesize = factory()); })(this, (function () { 'use strict'; - var symbol = { - iec: { - bits: ["bit", "Kibit", "Mibit", "Gibit", "Tibit", "Pibit", "Eibit", "Zibit", "Yibit"], - bytes: ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] + var strings = { + 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"] + } }, - 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"] } - }, - fullform = { - iec: ["", "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi", "yobi"], - jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"] }, roundingFuncs = { + ceil: Math.ceil, floor: Math.floor, - ceil: Math.ceil + round: Math.round }; /** * filesize @@ -39,53 +42,54 @@ */ function filesize(arg) { - var descriptor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var result = [], + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$bits = _ref.bits, + bits = _ref$bits === void 0 ? false : _ref$bits, + _ref$pad = _ref.pad, + pad = _ref$pad === void 0 ? false : _ref$pad, + _ref$base = _ref.base, + base = _ref$base === void 0 ? 10 : _ref$base, + _ref$round = _ref.round, + round = _ref$round === void 0 ? 2 : _ref$round, + _ref$locale = _ref.locale, + locale = _ref$locale === void 0 ? "" : _ref$locale, + _ref$localeOptions = _ref.localeOptions, + localeOptions = _ref$localeOptions === void 0 ? {} : _ref$localeOptions, + _ref$separator = _ref.separator, + separator = _ref$separator === void 0 ? "" : _ref$separator, + _ref$spacer = _ref.spacer, + spacer = _ref$spacer === void 0 ? " " : _ref$spacer, + _ref$symbols = _ref.symbols, + symbols = _ref$symbols === void 0 ? {} : _ref$symbols, + _ref$standard = _ref.standard, + standard = _ref$standard === void 0 ? "iec" : _ref$standard, + _ref$output = _ref.output, + output = _ref$output === void 0 ? "string" : _ref$output, + _ref$fullform = _ref.fullform, + fullform = _ref$fullform === void 0 ? false : _ref$fullform, + _ref$fullforms = _ref.fullforms, + fullforms = _ref$fullforms === void 0 ? [] : _ref$fullforms, + _ref$exponent = _ref.exponent, + exponent = _ref$exponent === void 0 ? -1 : _ref$exponent, + _ref$roundingMethod = _ref.roundingMethod, + roundingMethod = _ref$roundingMethod === void 0 ? "round" : _ref$roundingMethod, + _ref$precision = _ref.precision, + precision = _ref$precision === void 0 ? 0 : _ref$precision; + + var e = exponent, + num = Number(arg), + result = [], val = 0, - e, - base, - bits, - ceil, - full, - fullforms, - locale, - localeOptions, - neg, - num, - output, - pad, - round, - u, - separator, - spacer, - standard, - symbols, - roundingFunc, - precision; + u = ""; + var ceil = base === 10 ? 1000 : 1024, + full = fullform === true, + neg = num < 0, + roundingFunc = roundingFuncs[roundingMethod]; if (isNaN(arg)) { throw new TypeError("Invalid number"); - } + } // Flipping a negative number to determine the size - bits = descriptor.bits === true; - pad = descriptor.pad === true; - base = descriptor.base || 10; - round = descriptor.round !== void 0 ? descriptor.round : 2; - locale = descriptor.locale !== void 0 ? descriptor.locale : ""; - localeOptions = descriptor.localeOptions || {}; - separator = descriptor.separator !== void 0 ? descriptor.separator : ""; - spacer = descriptor.spacer !== void 0 ? descriptor.spacer : " "; - symbols = descriptor.symbols || {}; - standard = descriptor.standard in symbol ? descriptor.standard : "iec"; - output = descriptor.output || "string"; - full = descriptor.fullform === true; - fullforms = descriptor.fullforms instanceof Array ? descriptor.fullforms : []; - e = descriptor.exponent !== void 0 ? descriptor.exponent : -1; - roundingFunc = roundingFuncs[descriptor.roundingMethod] || Math.round; - num = Number(arg); - neg = num < 0; - ceil = base > 2 ? 1000 : 1024; - precision = isNaN(descriptor.precision) === false ? parseInt(descriptor.precision, 10) : 0; // Flipping a negative number to determine the size if (neg) { num = -num; @@ -116,7 +120,7 @@ if (num === 0) { result[0] = 0; - u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e]; + u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e]; } else { val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e)); @@ -132,12 +136,12 @@ var p = Math.pow(10, e > 0 ? round : 0); result[0] = roundingFunc(val * p) / p; - if (result[0] === ceil && e < 8 && descriptor.exponent === void 0) { + if (result[0] === ceil && e < 8 && exponent === -1) { result[0] = 1; e++; } - u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e]; + u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e]; } // Decorating a 'diff' @@ -171,7 +175,7 @@ } if (full) { - result[1] = fullforms[e] ? fullforms[e] : fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s"); + result[1] = fullforms[e] ? fullforms[e] : strings.fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s"); } // Returning Array, Object, or String (default) diff --git a/lib/filesize.min.js b/lib/filesize.min.js index a51d3c4..6f71db6 100644 --- a/lib/filesize.min.js +++ b/lib/filesize.min.js @@ -1,6 +1,6 @@ /*! 2022 Jason Mulligan - @version 9.0.0 + @version 9.0.1 */ -!function(i,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(i="undefined"!=typeof globalThis?globalThis:i||self).filesize=t()}(this,(function(){"use strict";var i={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"]}},t={iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]},e={floor:Math.floor,ceil:Math.ceil};function o(o){var n,r,a,b,s,l,c,d,f,p,u,g,h,B,y,M,m,v,x,N,T=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},E=[],j=0;if(isNaN(o))throw new TypeError("Invalid number");if(a=!0===T.bits,g=!0===T.pad,r=T.base||10,h=void 0!==T.round?T.round:2,c=void 0!==T.locale?T.locale:"",d=T.localeOptions||{},y=void 0!==T.separator?T.separator:"",M=void 0!==T.spacer?T.spacer:" ",v=T.symbols||{},m=T.standard in i?T.standard:"iec",u=T.output||"string",s=!0===T.fullform,l=T.fullforms instanceof Array?T.fullforms:[],n=void 0!==T.exponent?T.exponent:-1,x=e[T.roundingMethod]||Math.round,f=(p=Number(o))<0,b=r>2?1e3:1024,N=!1===isNaN(T.precision)?parseInt(T.precision,10):0,f&&(p=-p),(-1===n||isNaN(n))&&(n=Math.floor(Math.log(p)/Math.log(b)))<0&&(n=0),n>8&&(N>0&&(N+=8-n),n=8),"exponent"===u)return n;if(0===p)E[0]=0,B=E[1]=i[m][a?"bits":"bytes"][n];else{j=p/(2===r?Math.pow(2,10*n):Math.pow(1e3,n)),a&&(j*=8)>=b&&n<8&&(j/=b,n++);var w=Math.pow(10,n>0?h:0);E[0]=x(j*w)/w,E[0]===b&&n<8&&void 0===T.exponent&&(E[0]=1,n++),B=E[1]=i[m][a?"bits":"bytes"][n]}if(f&&(E[0]=-E[0]),N>0&&(E[0]=E[0].toPrecision(N)),E[1]=v[E[1]]||E[1],!0===c?E[0]=E[0].toLocaleString():c.length>0?E[0]=E[0].toLocaleString(c,d):y.length>0&&(E[0]=E[0].toString().replace(".",y)),g&&!1===Number.isInteger(E[0])&&h>0){var P=y||".",G=E[0].toString().split(P),K=G[1]||"",S=K.length,Y=h-S;E[0]="".concat(G[0]).concat(P).concat(K.padEnd(S+Y,"0"))}return s&&(E[1]=l[n]?l[n]:t[m][n]+(a?"bit":"byte")+(1===E[0]?"":"s")),"array"===u?E:"object"===u?{value:E[0],symbol:E[1],exponent:n,unit:B}:E.join(M)}return o.partial=function(i){return function(t){return o(t,i)}},o})); +!function(i,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(i="undefined"!=typeof globalThis?globalThis:i||self).filesize=t()}(this,(function(){"use strict";var i={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"]}},t={ceil:Math.ceil,floor:Math.floor,round:Math.round};function e(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=o.bits,r=void 0!==n&&n,b=o.pad,a=void 0!==b&&b,l=o.base,d=void 0===l?10:l,s=o.round,f=void 0===s?2:s,u=o.locale,c=void 0===u?"":u,p=o.localeOptions,v=void 0===p?{}:p,g=o.separator,h=void 0===g?"":g,y=o.spacer,B=void 0===y?" ":y,m=o.symbols,M=void 0===m?{}:m,x=o.standard,T=void 0===x?"iec":x,E=o.output,N=void 0===E?"string":E,j=o.fullform,w=void 0!==j&&j,P=o.fullforms,G=void 0===P?[]:P,K=o.exponent,S=void 0===K?-1:K,Y=o.roundingMethod,Z=void 0===Y?"round":Y,z=o.precision,k=void 0===z?0:z,I=S,L=Number(e),O=[],q=0,A="",C=10===d?1e3:1024,D=!0===w,F=L<0,H=t[Z];if(isNaN(e))throw new TypeError("Invalid number");if(F&&(L=-L),(-1===I||isNaN(I))&&(I=Math.floor(Math.log(L)/Math.log(C)))<0&&(I=0),I>8&&(k>0&&(k+=8-I),I=8),"exponent"===N)return I;if(0===L)O[0]=0,A=O[1]=i.symbol[T][r?"bits":"bytes"][I];else{q=L/(2===d?Math.pow(2,10*I):Math.pow(1e3,I)),r&&(q*=8)>=C&&I<8&&(q/=C,I++);var J=Math.pow(10,I>0?f:0);O[0]=H(q*J)/J,O[0]===C&&I<8&&-1===S&&(O[0]=1,I++),A=O[1]=i.symbol[T][r?"bits":"bytes"][I]}if(F&&(O[0]=-O[0]),k>0&&(O[0]=O[0].toPrecision(k)),O[1]=M[O[1]]||O[1],!0===c?O[0]=O[0].toLocaleString():c.length>0?O[0]=O[0].toLocaleString(c,v):h.length>0&&(O[0]=O[0].toString().replace(".",h)),a&&!1===Number.isInteger(O[0])&&f>0){var Q=h||".",R=O[0].toString().split(Q),U=R[1]||"",V=U.length,W=f-V;O[0]="".concat(R[0]).concat(Q).concat(U.padEnd(V+W,"0"))}return D&&(O[1]=G[I]?G[I]:i.fullform[T][I]+(r?"bit":"byte")+(1===O[0]?"":"s")),"array"===N?O:"object"===N?{value:O[0],symbol:O[1],exponent:I,unit:A}:O.join(B)}return e.partial=function(i){return function(t){return e(t,i)}},e})); //# sourceMappingURL=filesize.min.js.map diff --git a/lib/filesize.min.js.map b/lib/filesize.min.js.map index 9884568..a40fc65 100644 --- a/lib/filesize.min.js.map +++ b/lib/filesize.min.js.map @@ -1 +1 @@ -{"version":3,"file":"filesize.min.js","sources":["../src/filesize.js"],"sourcesContent":["const symbol = {\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\troundingFuncs = {\n\t\tfloor: Math.floor,\n\t\tceil: Math.ceil\n\t};\n\n/**\n * filesize\n *\n * @method filesize\n * @param {Mixed} arg String, Int or Float to transform\n * @param {Object} descriptor [Optional] Flags\n * @return {String} Readable file size String\n */\nfunction filesize (arg, descriptor = {}) {\n\tlet result = [],\n\t\tval = 0,\n\t\te, base, bits, ceil, full, fullforms, locale, localeOptions, neg, num, output, pad, round, u, separator, spacer, standard, symbols, roundingFunc, precision;\n\n\tif (isNaN(arg)) {\n\t\tthrow new TypeError(\"Invalid number\");\n\t}\n\n\tbits = descriptor.bits === true;\n\tpad = descriptor.pad === true;\n\tbase = descriptor.base || 10;\n\tround = descriptor.round !== void 0 ? descriptor.round : 2;\n\tlocale = descriptor.locale !== void 0 ? descriptor.locale : \"\";\n\tlocaleOptions = descriptor.localeOptions || {};\n\tseparator = descriptor.separator !== void 0 ? descriptor.separator : \"\";\n\tspacer = descriptor.spacer !== void 0 ? descriptor.spacer : \" \";\n\tsymbols = descriptor.symbols || {};\n\tstandard = descriptor.standard in symbol ? descriptor.standard : \"iec\";\n\toutput = descriptor.output || \"string\";\n\tfull = descriptor.fullform === true;\n\tfullforms = descriptor.fullforms instanceof Array ? descriptor.fullforms : [];\n\te = descriptor.exponent !== void 0 ? descriptor.exponent : -1;\n\troundingFunc = roundingFuncs[descriptor.roundingMethod] || Math.round;\n\tnum = Number(arg);\n\tneg = num < 0;\n\tceil = base > 2 ? 1000 : 1024;\n\tprecision = isNaN(descriptor.precision) === false ? parseInt(descriptor.precision, 10) : 0;\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\t\tu = result[1] = symbol[standard][bits ? \"bits\" : \"bytes\"][e];\n\t} else {\n\t\tval = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));\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\tconst 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 && descriptor.exponent === void 0) {\n\t\t\tresult[0] = 1;\n\t\t\te++;\n\t\t}\n\n\t\tu = result[1] = 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// Setting optional precision\n\tif (precision > 0) {\n\t\tresult[0] = result[0].toPrecision(precision);\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(\".\", separator);\n\t}\n\n\tif (pad && Number.isInteger(result[0]) === false && round > 0) {\n\t\tconst x = separator || \".\",\n\t\t\ttmp = result[0].toString().split(x),\n\t\t\ts = tmp[1] || \"\",\n\t\t\tl = s.length,\n\t\t\tn = round - l;\n\n\t\tresult[0] = `${tmp[0]}${x}${s.padEnd(l + n, \"0\")}`;\n\t}\n\n\tif (full) {\n\t\tresult[1] = fullforms[e] ? fullforms[e] : fullform[standard][e] + (bits ? \"bit\" : \"byte\") + (result[0] === 1 ? \"\" : \"s\");\n\t}\n\n\t// Returning Array, Object, or String (default)\n\treturn output === \"array\" ? result : output === \"object\" ? {value: result[0], symbol: result[1], exponent: e, unit: u} : result.join(spacer);\n}\n\n// Partial application for functional programming\nfilesize.partial = opt => arg => filesize(arg, opt);\n\nexport default filesize;\n"],"names":["symbol","iec","bits","bytes","jedec","fullform","roundingFuncs","floor","Math","ceil","filesize","arg","e","base","full","fullforms","locale","localeOptions","neg","num","output","pad","round","u","separator","spacer","standard","symbols","roundingFunc","precision","descriptor","result","val","isNaN","TypeError","Array","exponent","roundingMethod","Number","parseInt","log","pow","p","toPrecision","toLocaleString","length","toString","replace","isInteger","x","tmp","split","s","l","n","concat","padEnd","value","unit","join","partial","opt"],"mappings":";;;;yOAAA,IAAMA,EAAS,CACbC,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,EAAW,CACVJ,IAAK,CAAC,GAAI,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,QAClEG,MAAO,CAAC,GAAI,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,MAAO,QAAS,UAErEE,EAAgB,CACfC,MAAOC,KAAKD,MACZE,KAAMD,KAAKC,MAWb,SAASC,EAAUC,GAAsB,IAGvCC,EAAGC,EAAMX,EAAMO,EAAMK,EAAMC,EAAWC,EAAQC,EAAeC,EAAKC,EAAKC,EAAQC,EAAKC,EAAOC,EAAGC,EAAWC,EAAQC,EAAUC,EAASC,EAAcC,EAH5HC,yDAAa,GAChCC,EAAS,GACZC,EAAM,EAGP,GAAIC,MAAMtB,GACT,MAAM,IAAIuB,UAAU,kBA8CrB,GA3CAhC,GAA2B,IAApB4B,EAAW5B,KAClBmB,GAAyB,IAAnBS,EAAWT,IACjBR,EAAOiB,EAAWjB,MAAQ,GAC1BS,OAA6B,IAArBQ,EAAWR,MAAmBQ,EAAWR,MAAQ,EACzDN,OAA+B,IAAtBc,EAAW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iec: {\r\n\t\t\t\tbits: [\"bit\", \"Kibit\", \"Mibit\", \"Gibit\", \"Tibit\", \"Pibit\", \"Eibit\", \"Zibit\", \"Yibit\"],\r\n\t\t\t\tbytes: [\"B\", \"KiB\", \"MiB\", \"GiB\", \"TiB\", \"PiB\", \"EiB\", \"ZiB\", \"YiB\"]\r\n\t\t\t},\r\n\t\t\tjedec: {\r\n\t\t\t\tbits: [\"bit\", \"Kbit\", \"Mbit\", \"Gbit\", \"Tbit\", \"Pbit\", \"Ebit\", \"Zbit\", \"Ybit\"],\r\n\t\t\t\tbytes: [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"]\r\n\t\t\t}\r\n\t\t},\r\n\t\tfullform: {\r\n\t\t\tiec: [\"\", \"kibi\", \"mebi\", \"gibi\", \"tebi\", \"pebi\", \"exbi\", \"zebi\", \"yobi\"],\r\n\t\t\tjedec: [\"\", \"kilo\", \"mega\", \"giga\", \"tera\", \"peta\", \"exa\", \"zetta\", \"yotta\"]\r\n\t\t}\r\n\t},\r\n\troundingFuncs = {\r\n\t\tceil: Math.ceil,\r\n\t\tfloor: Math.floor,\r\n\t\tround: Math.round\r\n\t};\r\n\r\n/**\r\n * filesize\r\n *\r\n * @method filesize\r\n * @param {Mixed} arg String, Int or Float to transform\r\n * @param {Object} descriptor [Optional] Flags\r\n * @return {String} Readable file size String\r\n */\r\nfunction filesize (arg, {bits = false, pad = false, base = 10, round = 2, locale = \"\", localeOptions = {}, separator = \"\", spacer = \" \", symbols = {}, standard = \"iec\", output = \"string\", fullform = false, fullforms = [], exponent = -1, roundingMethod = \"round\", precision = 0} = {}) {\r\n\tlet e = exponent,\r\n\t\tnum = Number(arg),\r\n\t\tresult = [],\r\n\t\tval = 0,\r\n\t\tu = \"\";\r\n\tconst ceil = base === 10 ? 1000 : 1024,\r\n\t\tfull = fullform === true,\r\n\t\tneg = num < 0,\r\n\t\troundingFunc = roundingFuncs[roundingMethod];\r\n\r\n\tif (isNaN(arg)) {\r\n\t\tthrow new TypeError(\"Invalid number\");\r\n\t}\r\n\r\n\t// Flipping a negative number to determine the size\r\n\tif (neg) {\r\n\t\tnum = -num;\r\n\t}\r\n\r\n\t// Determining the exponent\r\n\tif (e === -1 || isNaN(e)) {\r\n\t\te = Math.floor(Math.log(num) / Math.log(ceil));\r\n\r\n\t\tif (e < 0) {\r\n\t\t\te = 0;\r\n\t\t}\r\n\t}\r\n\r\n\t// Exceeding supported length, time to reduce & multiply\r\n\tif (e > 8) {\r\n\t\tif (precision > 0) {\r\n\t\t\tprecision += 8 - e;\r\n\t\t}\r\n\r\n\t\te = 8;\r\n\t}\r\n\r\n\tif (output === \"exponent\") {\r\n\t\treturn e;\r\n\t}\r\n\r\n\t// Zero is now a special case because bytes divide by 1\r\n\tif (num === 0) {\r\n\t\tresult[0] = 0;\r\n\t\tu = result[1] = strings.symbol[standard][bits ? \"bits\" : \"bytes\"][e];\r\n\t} else {\r\n\t\tval = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));\r\n\r\n\t\tif (bits) {\r\n\t\t\tval = val * 8;\r\n\r\n\t\t\tif (val >= ceil && e < 8) {\r\n\t\t\t\tval = val / ceil;\r\n\t\t\t\te++;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst p = Math.pow(10, e > 0 ? round : 0);\r\n\t\tresult[0] = roundingFunc(val * p) / p;\r\n\r\n\t\tif (result[0] === ceil && e < 8 && exponent === -1) {\r\n\t\t\tresult[0] = 1;\r\n\t\t\te++;\r\n\t\t}\r\n\r\n\t\tu = result[1] = strings.symbol[standard][bits ? \"bits\" : \"bytes\"][e];\r\n\t}\r\n\r\n\t// Decorating a 'diff'\r\n\tif (neg) {\r\n\t\tresult[0] = -result[0];\r\n\t}\r\n\r\n\t// Setting optional precision\r\n\tif (precision > 0) {\r\n\t\tresult[0] = result[0].toPrecision(precision);\r\n\t}\r\n\r\n\t// Applying custom symbol\r\n\tresult[1] = symbols[result[1]] || result[1];\r\n\r\n\tif (locale === true) {\r\n\t\tresult[0] = result[0].toLocaleString();\r\n\t} else if (locale.length > 0) {\r\n\t\tresult[0] = result[0].toLocaleString(locale, localeOptions);\r\n\t} else if (separator.length > 0) {\r\n\t\tresult[0] = result[0].toString().replace(\".\", separator);\r\n\t}\r\n\r\n\tif (pad && Number.isInteger(result[0]) === false && round > 0) {\r\n\t\tconst x = separator || \".\",\r\n\t\t\ttmp = result[0].toString().split(x),\r\n\t\t\ts = tmp[1] || \"\",\r\n\t\t\tl = s.length,\r\n\t\t\tn = round - l;\r\n\r\n\t\tresult[0] = `${tmp[0]}${x}${s.padEnd(l + n, \"0\")}`;\r\n\t}\r\n\r\n\tif (full) {\r\n\t\tresult[1] = fullforms[e] ? fullforms[e] : strings.fullform[standard][e] + (bits ? \"bit\" : \"byte\") + (result[0] === 1 ? \"\" : \"s\");\r\n\t}\r\n\r\n\t// Returning Array, Object, or String (default)\r\n\treturn output === \"array\" ? result : output === \"object\" ? {value: result[0], symbol: result[1], exponent: e, unit: u} : result.join(spacer);\r\n}\r\n\r\n// Partial application for functional programming\r\nfilesize.partial = opt => arg => filesize(arg, opt);\r\n\r\nexport default filesize;\r\n"],"names":["strings","symbol","iec","bits","bytes","jedec","fullform","roundingFuncs","ceil","Math","floor","round","filesize","arg","_ref","arguments","length","undefined","_ref$bits","_ref$pad","pad","_ref$base","base","_ref$round","_ref$locale","locale","_ref$localeOptions","localeOptions","_ref$separator","separator","_ref$spacer","spacer","_ref$symbols","symbols","_ref$standard","standard","_ref$output","output","_ref$fullform","_ref$fullforms","fullforms","_ref$exponent","exponent","_ref$roundingMethod","roundingMethod","_ref$precision","precision","e","num","Number","result","val","u","full","neg","roundingFunc","isNaN","TypeError","log","pow","p","toPrecision","toLocaleString","toString","replace","isInteger","x","tmp","split","s","l","n","concat","padEnd","value","unit","join","partial","opt"],"mappings":";;;;yOAAA,IAAMA,EAAU,CACdC,OAAQ,CACPC,IAAK,CACJC,KAAM,CAAC,MAAO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EAAO,IAE1B,IAAXzB,EACHyB,EAAO,GAAKA,EAAO,GAAGY,iBACZrC,EAAOT,OAAS,EAC1BkC,EAAO,GAAKA,EAAO,GAAGY,eAAerC,EAAQE,GACnCE,EAAUb,OAAS,IAC7BkC,EAAO,GAAKA,EAAO,GAAGa,WAAWC,QAAQ,IAAKnC,IAG3CT,IAAuC,IAAhC6B,OAAOgB,UAAUf,EAAO,KAAiBvC,EAAQ,EAAG,CAC9D,IAAMuD,EAAIrC,GAAa,IACtBsC,EAAMjB,EAAO,GAAGa,WAAWK,MAAMF,GACjCG,EAAIF,EAAI,IAAM,GACdG,EAAID,EAAErD,OACNuD,EAAI5D,EAAQ2D,EAEbpB,EAAO,GAAP,GAAAsB,OAAeL,EAAI,IAAKD,OAAAA,UAAIG,EAAEI,OAAOH,EAAIC,EAAG,MAQ7C,OALIlB,IACHH,EAAO,GAAKV,EAAUO,GAAKP,EAAUO,GAAK/C,EAAQM,SAAS6B,GAAUY,IAAM5C,EAAO,MAAQ,SAAyB,IAAd+C,EAAO,GAAW,GAAK,MAI3G,UAAXb,EAAqBa,EAAoB,WAAXb,EAAsB,CAACqC,MAAOxB,EAAO,GAAIjD,OAAQiD,EAAO,GAAIR,SAAUK,EAAG4B,KAAMvB,GAAKF,EAAO0B,KAAK7C,UAItInB,EAASiE,QAAU,SAAAC,GAAG,OAAI,SAAAjE,GAAG,OAAID,EAASC,EAAKiE"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e706f99..72d6d9a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "filesize", - "version": "9.0.0", + "version": "9.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "filesize", - "version": "9.0.0", + "version": "9.0.1", "license": "BSD-3-Clause", "devDependencies": { "@babel/core": "^7.18.2", @@ -14,7 +14,7 @@ "auto-changelog": "^2.4.0", "eslint": "^8.16.0", "nodeunit-x": "^0.15.0", - "rollup": "^2.74.1", + "rollup": "^2.75.5", "rollup-plugin-babel": "^4.4.0", "rollup-plugin-terser": "^7.0.2", "typescript": "^4.7.2" @@ -452,9 +452,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.3.tgz", - "integrity": "sha512-rL50YcEuHbbauAFAysNsJA4/f89fGTOBRNs9P81sniKnKAr4xULe5AecolcsKbi88xu0ByWYDj/S1AJ3FSFuSQ==", + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.4.tgz", + "integrity": "sha512-FDge0dFazETFcxGw/EXzOkN8uJp0PC7Qbm+Pe9T+av2zlBpOgunFHkQPPn+eRuClU73JF+98D531UgayY89tow==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -983,9 +983,9 @@ } }, "node_modules/@babel/plugin-transform-block-scoping": { - "version": "7.17.12", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.17.12.tgz", - "integrity": "sha512-jw8XW/B1i7Lqwqj2CbrViPcZijSxfguBWZP2aN59NHgxUyO/OcO1mfdCxH13QhN5LbWhPkX+f+brKGhZTiqtZQ==", + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.18.4.tgz", + "integrity": "sha512-+Hq10ye+jlvLEogSOtq4mKvtk7qwcUQ1f0Mrueai866C82f844Yom2cttfJdMdqRLTxWpsbfbkIkOIfovyUQXw==", "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.17.12" @@ -998,17 +998,17 @@ } }, "node_modules/@babel/plugin-transform-classes": { - "version": "7.17.12", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.17.12.tgz", - "integrity": "sha512-cvO7lc7pZat6BsvH6l/EGaI8zpl8paICaoGk+7x7guvtfak/TbIf66nYmJOH13EuG0H+Xx3M+9LQDtSvZFKXKw==", + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.18.4.tgz", + "integrity": "sha512-e42NSG2mlKWgxKUAD9EJJSkZxR67+wZqzNxLSpc51T8tRU5SLFHsPmgYR5yr7sdgX4u+iHA1C5VafJ6AyImV3A==", "dev": true, "dependencies": { "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-environment-visitor": "^7.16.7", + "@babel/helper-environment-visitor": "^7.18.2", "@babel/helper-function-name": "^7.17.9", "@babel/helper-optimise-call-expression": "^7.16.7", "@babel/helper-plugin-utils": "^7.17.12", - "@babel/helper-replace-supers": "^7.16.7", + "@babel/helper-replace-supers": "^7.18.2", "@babel/helper-split-export-declaration": "^7.16.7", "globals": "^11.1.0" }, @@ -1194,9 +1194,9 @@ } }, "node_modules/@babel/plugin-transform-modules-systemjs": { - "version": "7.18.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.18.0.tgz", - "integrity": "sha512-vwKpxdHnlM5tIrRt/eA0bzfbi7gUBLN08vLu38np1nZevlPySRe6yvuATJB5F/WPJ+ur4OXwpVYq9+BsxqAQuQ==", + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.18.4.tgz", + "integrity": "sha512-lH2UaQaHVOAeYrUUuZ8i38o76J/FnO8vu21OE+tD1MyP9lxdZoSfz+pDbWkq46GogUrdrMz3tiz/FYGB+bVThg==", "dev": true, "dependencies": { "@babel/helper-hoist-variables": "^7.16.7", @@ -1596,9 +1596,9 @@ } }, "node_modules/@babel/types": { - "version": "7.18.2", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.18.2.tgz", - "integrity": "sha512-0On6B8A4/+mFUto5WERt3EEuG1NznDirvwca1O8UwXQHVY8g3R7OzYgxXdOfMwLO08UrpUD/2+3Bclyq+/C94Q==", + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.18.4.tgz", + "integrity": "sha512-ThN1mBcMq5pG/Vm2IcBmPPfyPXbd8S02rS+OBIDENdufvqC7Z/jHPCv9IcP01277aKtDI8g/2XysBN4hA8niiw==", "dev": true, "dependencies": { "@babel/helper-validator-identifier": "^7.16.7", @@ -1762,6 +1762,30 @@ "node": ">=6.0.0" } }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", + "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "node_modules/@jridgewell/source-map/node_modules/@jridgewell/gen-mapping": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.1.tgz", + "integrity": "sha512-GcHwniMlA2z+WFPWuY8lp3fsza0I8xPFMWL5+n8LYyP6PSvPrXf4+n8stDHZY2DM0zy9sVkRDy1jDI4XGzYVqg==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.0", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.13", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz", @@ -1779,9 +1803,9 @@ } }, "node_modules/@types/node": { - "version": "17.0.35", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.35.tgz", - "integrity": "sha512-vu1SrqBjbbZ3J6vwY17jBs8Sr/BKA+/a/WtjRG+whKg1iuLFOosq872EXS0eXWILdO36DHQQeku/ZcL6hz2fpg==", + "version": "17.0.38", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.38.tgz", + "integrity": "sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g==", "dev": true }, "node_modules/acorn": { @@ -2165,9 +2189,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001343", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001343.tgz", - "integrity": "sha512-8KeCrAtPMabo/XW14B+R9sZYoClx1n0b+WYgwDKZPtWR3TcdvWzdSy7mPyFEmR5WU1St9v1PW6sdO5dkFOEzfA==", + "version": "1.0.30001344", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001344.tgz", + "integrity": "sha512-0ZFjnlCaXNOAYcV7i+TtdKBp0L/3XEU2MF/x6Du1lrh+SRX4IfzIVL4HNJg5pB2PmFb8rszIGyOvsZnqqRoc2g==", "dev": true, "funding": [ { @@ -2313,7 +2337,7 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, "node_modules/convert-source-map": { @@ -2326,9 +2350,9 @@ } }, "node_modules/core-js-compat": { - "version": "3.22.7", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.22.7.tgz", - "integrity": "sha512-uI9DAQKKiiE/mclIC5g4AjRpio27g+VMRhe6rQoz+q4Wm4L6A/fJhiLtBw+sfOpDG9wZ3O0pxIw7GbfOlBgjOA==", + "version": "3.22.8", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.22.8.tgz", + "integrity": "sha512-pQnwg4xtuvc2Bs/5zYQPaEYYSuTxsF7LBWF0SvnVhthZo/Qe+rJpcEekrdNK5DWwDJ0gv0oI9NNX5Mppdy0ctg==", "dev": true, "dependencies": { "browserslist": "^4.20.3", @@ -2351,7 +2375,7 @@ "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==", "dev": true }, "node_modules/coveralls": { @@ -2412,7 +2436,7 @@ "node_modules/dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", "dev": true, "dependencies": { "assert-plus": "^1.0.0" @@ -2441,7 +2465,7 @@ "node_modules/decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -2484,7 +2508,7 @@ "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", "dev": true, "engines": { "node": ">=0.4.0" @@ -2514,7 +2538,7 @@ "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "integrity": "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==", "dev": true, "dependencies": { "jsbn": "~0.1.0", @@ -2537,9 +2561,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.139", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.139.tgz", - "integrity": "sha512-lYxzcUCjWxxVug+A7UxBCUiVr13TCjfZFYJS9Lq1VpU/ErwV4a6zUQo9dfojuGpw/L/x9REGuBl6ICQPGgbs3g==", + "version": "1.4.143", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.143.tgz", + "integrity": "sha512-2hIgvu0+pDfXIqmVmV5X6iwMjQ2KxDsWKwM+oI1fABEOy/Dqmll0QJRmIQ3rm+XaoUa/qKrmy5h7LSTFQ6Ldzg==", "dev": true }, "node_modules/emoji-regex": { @@ -2566,7 +2590,7 @@ "node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true, "engines": { "node": ">=0.8.0" @@ -2860,7 +2884,7 @@ "node_modules/events-to-array": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/events-to-array/-/events-to-array-1.1.2.tgz", - "integrity": "sha1-LUH1Y+H+QA7Uli/hpNXGp1Od9/Y=", + "integrity": "sha512-inRWzRY7nG+aXZxBzEqYKB3HPgwflZRopAjDCHv0whhRx+MTUr1ei0ICZUypdyE0HRm4L2d5VEcIqLD6yl+BFA==", "dev": true }, "node_modules/extend": { @@ -2872,7 +2896,7 @@ "node_modules/extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "integrity": "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==", "dev": true, "engines": [ "node >=0.6.0" @@ -2893,7 +2917,7 @@ "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "node_modules/file-entry-cache": { @@ -2983,7 +3007,7 @@ "node_modules/findit": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/findit/-/findit-2.0.0.tgz", - "integrity": "sha1-ZQnwEmr0wXhVHPqZOU4DLhOk1W4=", + "integrity": "sha512-ENZS237/Hr8bjczn5eKuBohLgaD0JyUd0arxretR1f9RO46vZHA1b2y0VorgGV3WaOT3c+78P8h7v4JGJ1i/rg==", "dev": true }, "node_modules/flat-cache": { @@ -3021,7 +3045,7 @@ "node_modules/forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "integrity": "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==", "dev": true, "engines": { "node": "*" @@ -3064,13 +3088,13 @@ "node_modules/fs-exists-cached": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-exists-cached/-/fs-exists-cached-1.0.0.tgz", - "integrity": "sha1-zyVVTKBQ3EmuZla0HeQiWJidy84=", + "integrity": "sha512-kSxoARUDn4F2RPXX48UXnaFKwVU7Ivd/6qpzZL29MCDmr9sTvybv4gFCp+qaI4fM9m0z9fgz/yJvi56GAz+BZg==", "dev": true }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "node_modules/fsevents": { @@ -3102,7 +3126,7 @@ "node_modules/functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", "dev": true }, "node_modules/gensync": { @@ -3149,7 +3173,7 @@ "node_modules/getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "integrity": "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==", "dev": true, "dependencies": { "assert-plus": "^1.0.0" @@ -3226,7 +3250,7 @@ "node_modules/har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "integrity": "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==", "dev": true, "engines": { "node": ">=4" @@ -3261,7 +3285,7 @@ "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, "engines": { "node": ">=4" @@ -3316,7 +3340,7 @@ "node_modules/http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "integrity": "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==", "dev": true, "dependencies": { "assert-plus": "^1.0.0", @@ -3356,7 +3380,7 @@ "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true, "engines": { "node": ">=0.8.19" @@ -3374,7 +3398,7 @@ "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "dependencies": { "once": "^1.3.0", @@ -3414,7 +3438,7 @@ "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -3465,7 +3489,7 @@ "node_modules/is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", "dev": true }, "node_modules/is-windows": { @@ -3480,13 +3504,13 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "node_modules/isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==", "dev": true }, "node_modules/istanbul-lib-coverage": { @@ -3761,7 +3785,7 @@ "node_modules/jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==", "dev": true }, "node_modules/jsesc": { @@ -3791,13 +3815,13 @@ "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, "node_modules/json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", "dev": true }, "node_modules/json5": { @@ -3830,7 +3854,7 @@ "node_modules/lcov-parse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-1.0.0.tgz", - "integrity": "sha1-6w1GtUER68VhrLTECO+TY73I9+A=", + "integrity": "sha512-aprLII/vPzuQvYZnDRU78Fns9I2Ag3gi4Ipga/hxnVMCZC8DnR2nI7XBqrPoywGfxqIx/DgarGvDJZAD3YBTgQ==", "dev": true, "bin": { "lcov-parse": "bin/cli.js" @@ -3891,13 +3915,13 @@ "node_modules/lodash.debounce": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", "dev": true }, "node_modules/lodash.flattendeep": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", - "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", + "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==", "dev": true }, "node_modules/lodash.merge": { @@ -3906,12 +3930,6 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, - "node_modules/lodash.sortby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", - "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", - "dev": true - }, "node_modules/log-driver": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz", @@ -4026,7 +4044,7 @@ "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, "node_modules/neo-async": { @@ -4184,7 +4202,7 @@ "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "dependencies": { "wrappy": "1" @@ -4219,7 +4237,7 @@ "node_modules/own-or": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/own-or/-/own-or-1.0.0.tgz", - "integrity": "sha1-Tod/vtqaLsgAD7wLyuOWRe6L+Nw=", + "integrity": "sha512-NfZr5+Tdf6MB8UI9GLvKRs4cXY8/yB0w3xtt84xFdWy8hkGjn+JFc60VhzS/hFRfbyxFcGYMTjnF4Me+RbbqrA==", "dev": true }, "node_modules/own-or-env": { @@ -4330,7 +4348,7 @@ "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true, "engines": { "node": ">=0.10.0" @@ -4354,7 +4372,7 @@ "node_modules/performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", "dev": true }, "node_modules/picocolors": { @@ -4536,7 +4554,7 @@ "node_modules/regjsparser/node_modules/jsesc": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", + "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==", "dev": true, "bin": { "jsesc": "bin/jsesc" @@ -4643,9 +4661,9 @@ } }, "node_modules/rollup": { - "version": "2.74.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.74.1.tgz", - "integrity": "sha512-K2zW7kV8Voua5eGkbnBtWYfMIhYhT9Pel2uhBk2WO5eMee161nPze/XRfvEQPFYz7KgrCCnmh2Wy0AMFLGGmMA==", + "version": "2.75.5", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.75.5.tgz", + "integrity": "sha512-JzNlJZDison3o2mOxVmb44Oz7t74EfSd1SQrplQk0wSaXV7uLQXtVdHbxlcT3w+8tZ1TL4r/eLfc7nAbz38BBA==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -6907,14 +6925,14 @@ } }, "node_modules/terser": { - "version": "5.13.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.13.1.tgz", - "integrity": "sha512-hn4WKOfwnwbYfe48NgrQjqNOH9jzLqRcIfbYytOXCOv46LBfWr9bDS17MQqOi+BWGD0sJK3Sj5NC/gJjiojaoA==", + "version": "5.14.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.14.0.tgz", + "integrity": "sha512-JC6qfIEkPBd9j1SMO3Pfn+A6w2kQV54tv+ABQLgZr7dA3k/DL/OBoYSWxzVpZev3J+bUHXfr55L8Mox7AaNo6g==", "dev": true, "dependencies": { + "@jridgewell/source-map": "^0.3.2", "acorn": "^8.5.0", "commander": "^2.20.0", - "source-map": "~0.8.0-beta.0", "source-map-support": "~0.5.20" }, "bin": { @@ -6930,44 +6948,6 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, - "node_modules/terser/node_modules/source-map": { - "version": "0.8.0-beta.0", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.8.0-beta.0.tgz", - "integrity": "sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==", - "dev": true, - "dependencies": { - "whatwg-url": "^7.0.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/terser/node_modules/tr46": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", - "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=", - "dev": true, - "dependencies": { - "punycode": "^2.1.0" - } - }, - "node_modules/terser/node_modules/webidl-conversions": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", - "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==", - "dev": true - }, - "node_modules/terser/node_modules/whatwg-url": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", - "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", - "dev": true, - "dependencies": { - "lodash.sortby": "^4.7.0", - "tr46": "^1.0.1", - "webidl-conversions": "^4.0.2" - } - }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", @@ -7779,9 +7759,9 @@ } }, "@babel/parser": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.3.tgz", - "integrity": "sha512-rL50YcEuHbbauAFAysNsJA4/f89fGTOBRNs9P81sniKnKAr4xULe5AecolcsKbi88xu0ByWYDj/S1AJ3FSFuSQ==", + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.4.tgz", + "integrity": "sha512-FDge0dFazETFcxGw/EXzOkN8uJp0PC7Qbm+Pe9T+av2zlBpOgunFHkQPPn+eRuClU73JF+98D531UgayY89tow==", "dev": true }, "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { @@ -8127,26 +8107,26 @@ } }, "@babel/plugin-transform-block-scoping": { - "version": "7.17.12", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.17.12.tgz", - "integrity": "sha512-jw8XW/B1i7Lqwqj2CbrViPcZijSxfguBWZP2aN59NHgxUyO/OcO1mfdCxH13QhN5LbWhPkX+f+brKGhZTiqtZQ==", + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.18.4.tgz", + "integrity": "sha512-+Hq10ye+jlvLEogSOtq4mKvtk7qwcUQ1f0Mrueai866C82f844Yom2cttfJdMdqRLTxWpsbfbkIkOIfovyUQXw==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.17.12" } }, "@babel/plugin-transform-classes": { - "version": "7.17.12", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.17.12.tgz", - "integrity": "sha512-cvO7lc7pZat6BsvH6l/EGaI8zpl8paICaoGk+7x7guvtfak/TbIf66nYmJOH13EuG0H+Xx3M+9LQDtSvZFKXKw==", + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.18.4.tgz", + "integrity": "sha512-e42NSG2mlKWgxKUAD9EJJSkZxR67+wZqzNxLSpc51T8tRU5SLFHsPmgYR5yr7sdgX4u+iHA1C5VafJ6AyImV3A==", "dev": true, "requires": { "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-environment-visitor": "^7.16.7", + "@babel/helper-environment-visitor": "^7.18.2", "@babel/helper-function-name": "^7.17.9", "@babel/helper-optimise-call-expression": "^7.16.7", "@babel/helper-plugin-utils": "^7.17.12", - "@babel/helper-replace-supers": "^7.16.7", + "@babel/helper-replace-supers": "^7.18.2", "@babel/helper-split-export-declaration": "^7.16.7", "globals": "^11.1.0" } @@ -8260,9 +8240,9 @@ } }, "@babel/plugin-transform-modules-systemjs": { - "version": "7.18.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.18.0.tgz", - "integrity": "sha512-vwKpxdHnlM5tIrRt/eA0bzfbi7gUBLN08vLu38np1nZevlPySRe6yvuATJB5F/WPJ+ur4OXwpVYq9+BsxqAQuQ==", + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.18.4.tgz", + "integrity": "sha512-lH2UaQaHVOAeYrUUuZ8i38o76J/FnO8vu21OE+tD1MyP9lxdZoSfz+pDbWkq46GogUrdrMz3tiz/FYGB+bVThg==", "dev": true, "requires": { "@babel/helper-hoist-variables": "^7.16.7", @@ -8548,9 +8528,9 @@ } }, "@babel/types": { - "version": "7.18.2", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.18.2.tgz", - "integrity": "sha512-0On6B8A4/+mFUto5WERt3EEuG1NznDirvwca1O8UwXQHVY8g3R7OzYgxXdOfMwLO08UrpUD/2+3Bclyq+/C94Q==", + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.18.4.tgz", + "integrity": "sha512-ThN1mBcMq5pG/Vm2IcBmPPfyPXbd8S02rS+OBIDENdufvqC7Z/jHPCv9IcP01277aKtDI8g/2XysBN4hA8niiw==", "dev": true, "requires": { "@babel/helper-validator-identifier": "^7.16.7", @@ -8676,6 +8656,29 @@ "integrity": "sha512-Ct5MqZkLGEXTVmQYbGtx9SVqD2fqwvdubdps5D3djjAkgkKwT918VNOz65pEHFaYTeWcukmJmH5SwsA9Tn2ObQ==", "dev": true }, + "@jridgewell/source-map": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", + "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "dev": true, + "requires": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "dependencies": { + "@jridgewell/gen-mapping": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.1.tgz", + "integrity": "sha512-GcHwniMlA2z+WFPWuY8lp3fsza0I8xPFMWL5+n8LYyP6PSvPrXf4+n8stDHZY2DM0zy9sVkRDy1jDI4XGzYVqg==", + "dev": true, + "requires": { + "@jridgewell/set-array": "^1.0.0", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + } + } + } + }, "@jridgewell/sourcemap-codec": { "version": "1.4.13", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz", @@ -8693,9 +8696,9 @@ } }, "@types/node": { - "version": "17.0.35", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.35.tgz", - "integrity": "sha512-vu1SrqBjbbZ3J6vwY17jBs8Sr/BKA+/a/WtjRG+whKg1iuLFOosq872EXS0eXWILdO36DHQQeku/ZcL6hz2fpg==", + "version": "17.0.38", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.38.tgz", + "integrity": "sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g==", "dev": true }, "acorn": { @@ -8987,9 +8990,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001343", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001343.tgz", - "integrity": "sha512-8KeCrAtPMabo/XW14B+R9sZYoClx1n0b+WYgwDKZPtWR3TcdvWzdSy7mPyFEmR5WU1St9v1PW6sdO5dkFOEzfA==", + "version": "1.0.30001344", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001344.tgz", + "integrity": "sha512-0ZFjnlCaXNOAYcV7i+TtdKBp0L/3XEU2MF/x6Du1lrh+SRX4IfzIVL4HNJg5pB2PmFb8rszIGyOvsZnqqRoc2g==", "dev": true }, "caseless": { @@ -9098,7 +9101,7 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, "convert-source-map": { @@ -9111,9 +9114,9 @@ } }, "core-js-compat": { - "version": "3.22.7", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.22.7.tgz", - "integrity": "sha512-uI9DAQKKiiE/mclIC5g4AjRpio27g+VMRhe6rQoz+q4Wm4L6A/fJhiLtBw+sfOpDG9wZ3O0pxIw7GbfOlBgjOA==", + "version": "3.22.8", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.22.8.tgz", + "integrity": "sha512-pQnwg4xtuvc2Bs/5zYQPaEYYSuTxsF7LBWF0SvnVhthZo/Qe+rJpcEekrdNK5DWwDJ0gv0oI9NNX5Mppdy0ctg==", "dev": true, "requires": { "browserslist": "^4.20.3", @@ -9131,7 +9134,7 @@ "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==", "dev": true }, "coveralls": { @@ -9182,7 +9185,7 @@ "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", "dev": true, "requires": { "assert-plus": "^1.0.0" @@ -9200,7 +9203,7 @@ "decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", "dev": true }, "deep-is": { @@ -9231,7 +9234,7 @@ "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", "dev": true }, "diff": { @@ -9252,7 +9255,7 @@ "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "integrity": "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==", "dev": true, "requires": { "jsbn": "~0.1.0", @@ -9269,9 +9272,9 @@ } }, "electron-to-chromium": { - "version": "1.4.139", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.139.tgz", - "integrity": "sha512-lYxzcUCjWxxVug+A7UxBCUiVr13TCjfZFYJS9Lq1VpU/ErwV4a6zUQo9dfojuGpw/L/x9REGuBl6ICQPGgbs3g==", + "version": "1.4.143", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.143.tgz", + "integrity": "sha512-2hIgvu0+pDfXIqmVmV5X6iwMjQ2KxDsWKwM+oI1fABEOy/Dqmll0QJRmIQ3rm+XaoUa/qKrmy5h7LSTFQ6Ldzg==", "dev": true }, "emoji-regex": { @@ -9295,7 +9298,7 @@ "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true }, "eslint": { @@ -9502,7 +9505,7 @@ "events-to-array": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/events-to-array/-/events-to-array-1.1.2.tgz", - "integrity": "sha1-LUH1Y+H+QA7Uli/hpNXGp1Od9/Y=", + "integrity": "sha512-inRWzRY7nG+aXZxBzEqYKB3HPgwflZRopAjDCHv0whhRx+MTUr1ei0ICZUypdyE0HRm4L2d5VEcIqLD6yl+BFA==", "dev": true }, "extend": { @@ -9514,7 +9517,7 @@ "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "integrity": "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==", "dev": true }, "fast-deep-equal": { @@ -9532,7 +9535,7 @@ "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "file-entry-cache": { @@ -9606,7 +9609,7 @@ "findit": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/findit/-/findit-2.0.0.tgz", - "integrity": "sha1-ZQnwEmr0wXhVHPqZOU4DLhOk1W4=", + "integrity": "sha512-ENZS237/Hr8bjczn5eKuBohLgaD0JyUd0arxretR1f9RO46vZHA1b2y0VorgGV3WaOT3c+78P8h7v4JGJ1i/rg==", "dev": true }, "flat-cache": { @@ -9638,7 +9641,7 @@ "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "integrity": "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==", "dev": true }, "form-data": { @@ -9661,13 +9664,13 @@ "fs-exists-cached": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-exists-cached/-/fs-exists-cached-1.0.0.tgz", - "integrity": "sha1-zyVVTKBQ3EmuZla0HeQiWJidy84=", + "integrity": "sha512-kSxoARUDn4F2RPXX48UXnaFKwVU7Ivd/6qpzZL29MCDmr9sTvybv4gFCp+qaI4fM9m0z9fgz/yJvi56GAz+BZg==", "dev": true }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "fsevents": { @@ -9692,7 +9695,7 @@ "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", "dev": true }, "gensync": { @@ -9727,7 +9730,7 @@ "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "integrity": "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==", "dev": true, "requires": { "assert-plus": "^1.0.0" @@ -9784,7 +9787,7 @@ "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "integrity": "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==", "dev": true }, "har-validator": { @@ -9809,7 +9812,7 @@ "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true }, "has-property-descriptors": { @@ -9846,7 +9849,7 @@ "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "integrity": "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==", "dev": true, "requires": { "assert-plus": "^1.0.0", @@ -9873,7 +9876,7 @@ "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true }, "indent-string": { @@ -9885,7 +9888,7 @@ "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "requires": { "once": "^1.3.0", @@ -9919,7 +9922,7 @@ "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true }, "is-fullwidth-code-point": { @@ -9952,7 +9955,7 @@ "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", "dev": true }, "is-windows": { @@ -9964,13 +9967,13 @@ "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==", "dev": true }, "istanbul-lib-coverage": { @@ -10182,7 +10185,7 @@ "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==", "dev": true }, "jsesc": { @@ -10206,13 +10209,13 @@ "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", "dev": true }, "json5": { @@ -10236,7 +10239,7 @@ "lcov-parse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-1.0.0.tgz", - "integrity": "sha1-6w1GtUER68VhrLTECO+TY73I9+A=", + "integrity": "sha512-aprLII/vPzuQvYZnDRU78Fns9I2Ag3gi4Ipga/hxnVMCZC8DnR2nI7XBqrPoywGfxqIx/DgarGvDJZAD3YBTgQ==", "dev": true }, "levn": { @@ -10282,13 +10285,13 @@ "lodash.debounce": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", "dev": true }, "lodash.flattendeep": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", - "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", + "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==", "dev": true }, "lodash.merge": { @@ -10297,12 +10300,6 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, - "lodash.sortby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", - "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", - "dev": true - }, "log-driver": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz", @@ -10387,7 +10384,7 @@ "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, "neo-async": { @@ -10506,7 +10503,7 @@ "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "requires": { "wrappy": "1" @@ -10535,7 +10532,7 @@ "own-or": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/own-or/-/own-or-1.0.0.tgz", - "integrity": "sha1-Tod/vtqaLsgAD7wLyuOWRe6L+Nw=", + "integrity": "sha512-NfZr5+Tdf6MB8UI9GLvKRs4cXY8/yB0w3xtt84xFdWy8hkGjn+JFc60VhzS/hFRfbyxFcGYMTjnF4Me+RbbqrA==", "dev": true }, "own-or-env": { @@ -10616,7 +10613,7 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true }, "path-key": { @@ -10634,7 +10631,7 @@ "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", "dev": true }, "picocolors": { @@ -10777,7 +10774,7 @@ "jsesc": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", + "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==", "dev": true } } @@ -10858,9 +10855,9 @@ } }, "rollup": { - "version": "2.74.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.74.1.tgz", - "integrity": "sha512-K2zW7kV8Voua5eGkbnBtWYfMIhYhT9Pel2uhBk2WO5eMee161nPze/XRfvEQPFYz7KgrCCnmh2Wy0AMFLGGmMA==", + "version": "2.75.5", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.75.5.tgz", + "integrity": "sha512-JzNlJZDison3o2mOxVmb44Oz7t74EfSd1SQrplQk0wSaXV7uLQXtVdHbxlcT3w+8tZ1TL4r/eLfc7nAbz38BBA==", "dev": true, "requires": { "fsevents": "~2.3.2" @@ -12381,14 +12378,14 @@ } }, "terser": { - "version": "5.13.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.13.1.tgz", - "integrity": "sha512-hn4WKOfwnwbYfe48NgrQjqNOH9jzLqRcIfbYytOXCOv46LBfWr9bDS17MQqOi+BWGD0sJK3Sj5NC/gJjiojaoA==", + "version": "5.14.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.14.0.tgz", + "integrity": "sha512-JC6qfIEkPBd9j1SMO3Pfn+A6w2kQV54tv+ABQLgZr7dA3k/DL/OBoYSWxzVpZev3J+bUHXfr55L8Mox7AaNo6g==", "dev": true, "requires": { + "@jridgewell/source-map": "^0.3.2", "acorn": "^8.5.0", "commander": "^2.20.0", - "source-map": "~0.8.0-beta.0", "source-map-support": "~0.5.20" }, "dependencies": { @@ -12397,41 +12394,6 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true - }, - "source-map": { - "version": "0.8.0-beta.0", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.8.0-beta.0.tgz", - "integrity": "sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==", - "dev": true, - "requires": { - "whatwg-url": "^7.0.0" - } - }, - "tr46": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", - "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=", - "dev": true, - "requires": { - "punycode": "^2.1.0" - } - }, - "webidl-conversions": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", - "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==", - "dev": true - }, - "whatwg-url": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", - "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", - "dev": true, - "requires": { - "lodash.sortby": "^4.7.0", - "tr46": "^1.0.1", - "webidl-conversions": "^4.0.2" - } } } }, diff --git a/package.json b/package.json index 04c4dc9..b44d944 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": "9.0.0", + "version": "9.0.1", "homepage": "https://filesizejs.com", "author": "Jason Mulligan ", "repository": { @@ -38,7 +38,7 @@ "auto-changelog": "^2.4.0", "eslint": "^8.16.0", "nodeunit-x": "^0.15.0", - "rollup": "^2.74.1", + "rollup": "^2.75.5", "rollup-plugin-babel": "^4.4.0", "rollup-plugin-terser": "^7.0.2", "typescript": "^4.7.2" diff --git a/src/filesize.js b/src/filesize.js index 92557a8..b05400d 100644 --- a/src/filesize.js +++ b/src/filesize.js @@ -1,20 +1,23 @@ -const symbol = { - iec: { - bits: ["bit", "Kibit", "Mibit", "Gibit", "Tibit", "Pibit", "Eibit", "Zibit", "Yibit"], - bytes: ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] +const strings = { + 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"] + } }, - 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"] } }, - fullform = { - iec: ["", "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi", "yobi"], - jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"] - }, roundingFuncs = { + ceil: Math.ceil, floor: Math.floor, - ceil: Math.ceil + round: Math.round }; /** @@ -25,35 +28,21 @@ const symbol = { * @param {Object} descriptor [Optional] Flags * @return {String} Readable file size String */ -function filesize (arg, descriptor = {}) { - let result = [], +function filesize (arg, {bits = false, pad = false, base = 10, round = 2, locale = "", localeOptions = {}, separator = "", spacer = " ", symbols = {}, standard = "iec", output = "string", fullform = false, fullforms = [], exponent = -1, roundingMethod = "round", precision = 0} = {}) { + let e = exponent, + num = Number(arg), + result = [], val = 0, - e, base, bits, ceil, full, fullforms, locale, localeOptions, neg, num, output, pad, round, u, separator, spacer, standard, symbols, roundingFunc, precision; + u = ""; + const ceil = base === 10 ? 1000 : 1024, + full = fullform === true, + neg = num < 0, + roundingFunc = roundingFuncs[roundingMethod]; if (isNaN(arg)) { throw new TypeError("Invalid number"); } - bits = descriptor.bits === true; - pad = descriptor.pad === true; - base = descriptor.base || 10; - round = descriptor.round !== void 0 ? descriptor.round : 2; - locale = descriptor.locale !== void 0 ? descriptor.locale : ""; - localeOptions = descriptor.localeOptions || {}; - separator = descriptor.separator !== void 0 ? descriptor.separator : ""; - spacer = descriptor.spacer !== void 0 ? descriptor.spacer : " "; - symbols = descriptor.symbols || {}; - standard = descriptor.standard in symbol ? descriptor.standard : "iec"; - output = descriptor.output || "string"; - full = descriptor.fullform === true; - fullforms = descriptor.fullforms instanceof Array ? descriptor.fullforms : []; - e = descriptor.exponent !== void 0 ? descriptor.exponent : -1; - roundingFunc = roundingFuncs[descriptor.roundingMethod] || Math.round; - num = Number(arg); - neg = num < 0; - ceil = base > 2 ? 1000 : 1024; - precision = isNaN(descriptor.precision) === false ? parseInt(descriptor.precision, 10) : 0; - // Flipping a negative number to determine the size if (neg) { num = -num; @@ -84,7 +73,7 @@ function filesize (arg, descriptor = {}) { // Zero is now a special case because bytes divide by 1 if (num === 0) { result[0] = 0; - u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e]; + u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e]; } else { val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e)); @@ -100,12 +89,12 @@ function filesize (arg, descriptor = {}) { const p = Math.pow(10, e > 0 ? round : 0); result[0] = roundingFunc(val * p) / p; - if (result[0] === ceil && e < 8 && descriptor.exponent === void 0) { + if (result[0] === ceil && e < 8 && exponent === -1) { result[0] = 1; e++; } - u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e]; + u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e]; } // Decorating a 'diff' @@ -140,7 +129,7 @@ function filesize (arg, descriptor = {}) { } if (full) { - result[1] = fullforms[e] ? fullforms[e] : fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s"); + result[1] = fullforms[e] ? fullforms[e] : strings.fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s"); } // Returning Array, Object, or String (default) diff --git a/test/filesize_test.js b/test/filesize_test.js index 16a5ffa..0e96a51 100644 --- a/test/filesize_test.js +++ b/test/filesize_test.js @@ -16,7 +16,7 @@ exports.filesize = { done(); }, base2: function (test) { - test.expect(40); + test.expect(39); test.equal(filesize(this.kilobit, {base: 2}), "500 B", "Should be '500 B'"); test.equal(filesize(this.kilobit, {base: 2, round: 1}), "500 B", "Should be '500 B'"); test.equal(filesize(this.kilobit, {base: 2, round: 1, spacer: ""}), "500B", "Should be '500B'"); @@ -28,7 +28,6 @@ exports.filesize = { test.equal(filesize(this.edgecase, {base: 2, round: 1}), "1023 B", "Should be '1023 B'"); test.equal(filesize(this.kibibyte, {base: 2}), "1 KiB", "Should be '1 KiB'"); test.equal(filesize(this.kibibyte, {base: 2, standard: "jedec"}), "1 KB", "Should be '1 KB'"); - test.equal(filesize(this.kibibyte, {base: 2, standard: "invalid"}), "1 KiB", "Should be '1 KiB'"); test.equal(filesize(this.kibibyte, {base: 2, round: 1}), "1 KiB", "Should be '1 KiB'"); test.equal(filesize(this.kibibyte, {base: 2, round: 1, spacer: ""}), "1KiB", "Should be '1KiB'"); test.equal(filesize(this.kibibyte, {base: 2, bits: true}), "8 Kibit", "Should be '8 Kibit'");