Son CV dans un terminal web en Javascript!
https://terminal-cv.gregandev.fr
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
8.7 KiB
1 lines
8.7 KiB
{"version":3,"file":"filesize.min.js","sources":["../src/filesize.js"],"sourcesContent":["const b = /^(b|B)$/,\n\tsymbol = {\n\t\tiec: {\n\t\t\tbits: [\"b\", \"Kib\", \"Mib\", \"Gib\", \"Tib\", \"Pib\", \"Eib\", \"Zib\", \"Yib\"],\n\t\t\tbytes: [\"B\", \"KiB\", \"MiB\", \"GiB\", \"TiB\", \"PiB\", \"EiB\", \"ZiB\", \"YiB\"]\n\t\t},\n\t\tjedec: {\n\t\t\tbits: [\"b\", \"Kb\", \"Mb\", \"Gb\", \"Tb\", \"Pb\", \"Eb\", \"Zb\", \"Yb\"],\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, unix, 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\tunix = descriptor.unix === true;\n\tpad = descriptor.pad === true;\n\tbase = descriptor.base || 2;\n\tround = descriptor.round !== void 0 ? descriptor.round : unix ? 1 : 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 : unix ? \"\" : \" \";\n\tsymbols = descriptor.symbols || {};\n\tstandard = base === 2 ? descriptor.standard || \"jedec\" : \"jedec\";\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] = unix ? \"\" : 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] = base === 10 && e === 1 ? bits ? \"kb\" : \"kB\" : symbol[standard][bits ? \"bits\" : \"bytes\"][e];\n\n\t\tif (unix) {\n\t\t\tresult[1] = standard === \"jedec\" ? result[1].charAt(0) : e > 0 ? result[1].replace(/B$/, \"\") : result[1];\n\n\t\t\tif (b.test(result[1])) {\n\t\t\t\tresult[0] = Math.floor(result[0]);\n\t\t\t\tresult[1] = \"\";\n\t\t\t}\n\t\t}\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":["b","symbol","iec","bits","bytes","jedec","fullform","roundingFuncs","floor","Math","ceil","filesize","arg","e","base","full","fullforms","locale","localeOptions","neg","num","output","pad","round","u","unix","separator","spacer","standard","symbols","roundingFunc","precision","descriptor","result","val","isNaN","TypeError","Array","exponent","roundingMethod","Number","parseInt","log","pow","p","charAt","replace","test","toPrecision","toLocaleString","length","toString","isInteger","x","tmp","split","s","l","n","padEnd","value","unit","join","partial","opt"],"mappings":";;;;yOAAA,IAAMA,EAAI,UACTC,EAAS,CACRC,IAAK,CACJC,KAAM,CAAC,IAAK,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,OAC7DC,MAAO,CAAC,IAAK,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,QAE/DC,MAAO,CACNF,KAAM,CAAC,IAAK,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,MACtDC,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,OAGjBC,EAAGC,EAAMX,EAAMO,EAAMK,EAAMC,EAAWC,EAAQC,EAAeC,EAAKC,EAAKC,EAAQC,EAAKC,EAAOC,EAAGC,EAAMC,EAAWC,EAAQC,EAAUC,EAASC,EAAcC,EAHlIC,yDAAa,GAChCC,EAAS,GACZC,EAAM,KAGHC,MAAMvB,SACH,IAAIwB,UAAU,qBAGrBjC,GAA2B,IAApB6B,EAAW7B,KAClBsB,GAA2B,IAApBO,EAAWP,KAClBH,GAAyB,IAAnBU,EAAWV,IACjBR,EAAOkB,EAAWlB,MAAQ,EAC1BS,OA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