initial commit of actions

This commit is contained in:
Dominik Polakovics Polakovics 2026-01-31 18:56:04 +01:00
commit 949ece5785
44660 changed files with 12034344 additions and 0 deletions

View file

@ -0,0 +1,28 @@
Copyright (c) 2022, Jason Mulligan
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of filesize nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,78 @@
# filesize.js
[![build status](https://secure.travis-ci.org/avoidwork/filesize.js.svg)](http://travis-ci.org/avoidwork/filesize.js) [![downloads](https://img.shields.io/npm/dt/filesize.svg)](https://www.npmjs.com/package/filesize) [![CDNJS version](https://img.shields.io/cdnjs/v/filesize.svg)](https://cdnjs.com/libraries/filesize)
filesize.js provides a simple way to get a human readable file size string from a number (float or integer) or string.
## Optional settings
`filesize()` accepts an optional descriptor Object as a second argument, so you can customize the output.
### base
_*(number)*_ Number base, default is `10`
### bits
_*(boolean)*_ Enables `bit` sizes, default is `false`
### exponent
_*(number)*_ Specifies the symbol via exponent, e.g. `2` is `MB` for base 2, default is `-1`
### fullform
_*(boolean)*_ Enables full form of unit of measure, default is `false`
### fullforms
_*(array)*_ Array of full form overrides, default is `[]`
### locale (overrides 'separator')
_*(string || boolean)*_ BCP 47 language tag to specify a locale, or `true` to use default locale, default is `""`
### localeOptions (overrides 'separator', requires string for 'locale' option)
_*(object)*_ Dictionary of options defined by ECMA-402 ([Number.prototype.toLocaleString](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)). Requires locale option to be explicitly passed as a string, otherwise is ignored.
### output
_*(string)*_ Output of function (`array`, `exponent`, `object`, or `string`), default is `string`
### pad
_*(boolean)*_ Decimal place end padding, default is `false`
### precision
_*(number)*_ Sets precision of numerical output, default is `0`
### round
_*(number)*_ Decimal place, default is `2`
### roundingMethod
_*(string)*_ Rounding method, can be `round`, `floor`, or `ceil`, default is `round`
### separator
_*(string)*_ Decimal separator character, default is `.`
### spacer
_*(string)*_ Character between the `result` and `symbol`, default is `" "`
### standard
_*(string)*_ Standard unit of measure, can be `iec` or `jedec`, default is `iec`; can be overruled by `base`
### symbols
_*(object)*_ Dictionary of IEC/JEDEC symbols to replace for localization, defaults to english if no match is found
## Partial Application
`filesize.partial()` takes the second parameter of `filesize()` and returns a new function with the configuration applied
upon execution. This can be used to reduce `Object` creation if you call `filesize()` without caching the `descriptor`
in lexical scope.
```javascript
const size = filesize.partial({base: 2, standard: "jedec"});
size(265318); // "259.1 KB"
```
## How can I load filesize.js?
filesize.js supports AMD loaders (require.js, curl.js, etc.), node.js & npm (```npm install filesize```), or using a script tag.
An ES6 version is bundled with an npm install, but requires you load it with the full path, e.g. `require(path.join(__dirname, 'node_modules', 'filesize', 'lib', 'filesize.es6.js'))`.
## License
Copyright (c) 2022 Jason Mulligan
Licensed under the BSD-3 license.

View file

@ -0,0 +1,131 @@
// Type definitions for filesize 8.0.3
// Project: https://github.com/avoidwork/filesize.js, https://filesizejs.com
// Definitions by: Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>
// Renaud Chaput <https://github.com/renchap>
// Roman Nuritdinov <https://github.com/Ky6uk>
// Sam Hulick <https://github.com/ffxsam>
// Tomoto S. Washio <https://github.com/tomoto>
declare var fileSize: Filesize.Filesize;
export = fileSize;
export as namespace filesize;
declare namespace Filesize {
interface SiJedecBits {
b?: string;
Kb?: string;
Mb?: string;
Gb?: string;
Tb?: string;
Pb?: string;
Eb?: string;
Zb?: string;
Yb?: string;
}
interface SiJedecBytes {
B?: string;
KB?: string;
MB?: string;
GB?: string;
TB?: string;
PB?: string;
EB?: string;
ZB?: string;
YB?: string;
}
type SiJedec = SiJedecBits & SiJedecBytes & { [name: string]: string };
interface Options {
/**
* Number base, default is 10
*/
base?: number;
/**
* Enables bit sizes, default is false
*/
bits?: boolean;
/**
* Specifies the SI suffix via exponent, e.g. 2 is MB for bytes, default is -1
*/
exponent?: number;
/**
* Enables full form of unit of measure, default is false
*/
fullform?: boolean;
/**
* Array of full form overrides, default is []
*/
fullforms?: string[];
/**
* BCP 47 language tag to specify a locale, or true to use default locale, default is ""
*/
locale?: string | boolean;
/**
* ECMA-402 number format option overrides, default is "{}"
*/
localeOptions?: Intl.NumberFormatOptions;
/**
* Output of function (array, exponent, object, or string), default is string
*/
output?: "array" | "exponent" | "object" | "string";
/**
* Decimal place end padding, default is false
*/
pad?: boolean;
/**
* Sets precision of numerical output, default is 0
*/
precision?: number;
/**
* Decimal place, default is 2
*/
round?: number;
/**
* Rounding method, can be round, floor, or ceil, default is round
*/
roundingMethod?: "round" | "floor" | "ceil";
/**
* Decimal separator character, default is `.`
*/
separator?: string;
/**
* Character between the result and suffix, default is ` `
*/
spacer?: string;
/**
* Standard unit of measure, can be iec or jedec, default is iec; can be overruled by base
*/
standard?: "iec" | "jedec";
/**
* Dictionary of SI/JEDEC symbols to replace for localization, defaults to english if no match is found
*/
symbols?: SiJedec;
/**
* Enables unix style human readable output, e.g ls -lh, default is false
*/
unix?: boolean;
}
// Result type inference from the output option
interface ResultTypeMap<O> {
array: [O extends {precision: number} ? string : number, string];
exponent: number;
object: {
value: number,
symbol: string,
exponent: number,
unit: string,
};
string: string;
}
type DefaultOutput<O extends Options> = Exclude<O["output"], keyof ResultTypeMap<O>> extends never ? never : "string"
type CanonicalOutput<O extends Options> = Extract<O["output"], keyof ResultTypeMap<O>> | DefaultOutput<O>
interface Filesize {
(bytes: number): string;
<O extends Options>(bytes: number, options: O): ResultTypeMap<O>[CanonicalOutput<O>];
partial: <O extends Options>(options: O) => ((bytes: number) => ResultTypeMap<O>[CanonicalOutput<O>]);
}
}

View file

@ -0,0 +1,213 @@
/**
* filesize
*
* @copyright 2022 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 9.0.11
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.filesize = factory());
})(this, (function () { 'use strict';
const ARRAY = "array";
const BIT = "bit";
const BITS = "bits";
const BYTE = "byte";
const BYTES = "bytes";
const EMPTY = "";
const EXPONENT = "exponent";
const FUNCTION = "function";
const IEC = "iec";
const INVALID_NUMBER = "Invalid number";
const INVALID_ROUND = "Invalid rounding method";
const JEDEC = "jedec";
const OBJECT = "object";
const PERIOD = ".";
const ROUND = "round";
const S = "s";
const SI_KBIT = "kbit";
const SI_KBYTE = "kB";
const SPACE = " ";
const STRING = "string";
const ZERO = "0";
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"]
}
},
fullform: {
iec: ["", "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi", "yobi"],
jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"]
}
};
/**
* filesize
*
* @method filesize
* @param {Mixed} arg String, Int or Float to transform
* @param {Object} descriptor [Optional] Flags
* @return {String} Readable file size String
*/
function filesize (arg, {
bits = false,
pad = false,
base = -1,
round = 2,
locale = EMPTY,
localeOptions = {},
separator = EMPTY,
spacer = SPACE,
symbols = {},
standard = EMPTY,
output = STRING,
fullform = false,
fullforms = [],
exponent = -1,
roundingMethod = ROUND,
precision = 0
} = {}) {
let e = exponent,
num = Number(arg),
result = [],
val = 0,
u = EMPTY;
// Sync base & standard
if (base === -1 && standard.length === 0) {
base = 10;
standard = JEDEC;
} else if (base === -1 && standard.length > 0) {
standard = standard === IEC ? IEC : JEDEC;
base = standard === IEC ? 2 : 10;
} else {
base = base === 2 ? 2 : 10;
standard = base === 10 ? JEDEC : standard === JEDEC ? JEDEC : IEC;
}
const ceil = base === 10 ? 1000 : 1024,
full = fullform === true,
neg = num < 0,
roundingFunc = Math[roundingMethod];
if (isNaN(arg)) {
throw new TypeError(INVALID_NUMBER);
}
if (typeof roundingFunc !== FUNCTION) {
throw new TypeError(INVALID_ROUND);
}
// Flipping a negative number to determine the size
if (neg) {
num = -num;
}
// Determining the exponent
if (e === -1 || isNaN(e)) {
e = Math.floor(Math.log(num) / Math.log(ceil));
if (e < 0) {
e = 0;
}
}
// Exceeding supported length, time to reduce & multiply
if (e > 8) {
if (precision > 0) {
precision += 8 - e;
}
e = 8;
}
if (output === EXPONENT) {
return e;
}
// Zero is now a special case because bytes divide by 1
if (num === 0) {
result[0] = 0;
u = result[1] = strings.symbol[standard][bits ? BITS : BYTES][e];
} else {
val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));
if (bits) {
val = val * 8;
if (val >= ceil && e < 8) {
val = val / ceil;
e++;
}
}
const p = Math.pow(10, e > 0 ? round : 0);
result[0] = roundingFunc(val * p) / p;
if (result[0] === ceil && e < 8 && exponent === -1) {
result[0] = 1;
e++;
}
u = result[1] = base === 10 && e === 1 ? bits ? SI_KBIT : SI_KBYTE : strings.symbol[standard][bits ? BITS : BYTES][e];
}
// Decorating a 'diff'
if (neg) {
result[0] = -result[0];
}
// Setting optional precision
if (precision > 0) {
result[0] = result[0].toPrecision(precision);
}
// Applying custom symbol
result[1] = symbols[result[1]] || result[1];
if (locale === true) {
result[0] = result[0].toLocaleString();
} else if (locale.length > 0) {
result[0] = result[0].toLocaleString(locale, localeOptions);
} else if (separator.length > 0) {
result[0] = result[0].toString().replace(PERIOD, separator);
}
if (pad && Number.isInteger(result[0]) === false && round > 0) {
const x = separator || PERIOD,
tmp = result[0].toString().split(x),
s = tmp[1] || EMPTY,
l = s.length,
n = round - l;
result[0] = `${tmp[0]}${x}${s.padEnd(l + n, ZERO)}`;
}
if (full) {
result[1] = fullforms[e] ? fullforms[e] : strings.fullform[standard][e] + (bits ? BIT : BYTE) + (result[0] === 1 ? EMPTY : S);
}
// Returning Array, Object, or String (default)
return output === ARRAY ? result : output === OBJECT ? {
value: result[0],
symbol: result[1],
exponent: e,
unit: u
} : result.join(spacer);
}
// Partial application for functional programming
filesize.partial = opt => arg => filesize(arg, opt);
return filesize;
}));

View file

@ -0,0 +1,6 @@
/*!
2022 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 9.0.11
*/
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t="undefined"!=typeof globalThis?globalThis:t||self).filesize=i()}(this,(function(){"use strict";const t="bits",i="bytes",e="",o="iec",n="jedec",b={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function r(r,{bits:l=!1,pad:s=!1,base:a=-1,round:f=2,locale:u="",localeOptions:p={},separator:c="",spacer:d=" ",symbols:g={},standard:h="",output:y="string",fullform:B=!1,fullforms:m=[],exponent:M=-1,roundingMethod:T="round",precision:w=0}={}){let x=M,E=Number(r),j=[],N=0,P=e;-1===a&&0===h.length?(a=10,h=n):-1===a&&h.length>0?a=(h=h===o?o:n)===o?2:10:h=10===(a=2===a?2:10)||h===n?n:o;const k=10===a?1e3:1024,G=!0===B,K=E<0,S=Math[T];if(isNaN(r))throw new TypeError("Invalid number");if("function"!=typeof S)throw new TypeError("Invalid rounding method");if(K&&(E=-E),(-1===x||isNaN(x))&&(x=Math.floor(Math.log(E)/Math.log(k)),x<0&&(x=0)),x>8&&(w>0&&(w+=8-x),x=8),"exponent"===y)return x;if(0===E)j[0]=0,P=j[1]=b.symbol[h][l?t:i][x];else{N=E/(2===a?Math.pow(2,10*x):Math.pow(1e3,x)),l&&(N*=8,N>=k&&x<8&&(N/=k,x++));const e=Math.pow(10,x>0?f:0);j[0]=S(N*e)/e,j[0]===k&&x<8&&-1===M&&(j[0]=1,x++),P=j[1]=10===a&&1===x?l?"kbit":"kB":b.symbol[h][l?t:i][x]}if(K&&(j[0]=-j[0]),w>0&&(j[0]=j[0].toPrecision(w)),j[1]=g[j[1]]||j[1],!0===u?j[0]=j[0].toLocaleString():u.length>0?j[0]=j[0].toLocaleString(u,p):c.length>0&&(j[0]=j[0].toString().replace(".",c)),s&&!1===Number.isInteger(j[0])&&f>0){const t=c||".",i=j[0].toString().split(t),o=i[1]||e,n=o.length,b=f-n;j[0]=`${i[0]}${t}${o.padEnd(n+b,"0")}`}return G&&(j[1]=m[x]?m[x]:b.fullform[h][x]+(l?"bit":"byte")+(1===j[0]?e:"s")),"array"===y?j:"object"===y?{value:j[0],symbol:j[1],exponent:x,unit:P}:j.join(d)}return r.partial=t=>i=>r(i,t),r}));
//# sourceMappingURL=filesize.es6.min.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,205 @@
/**
* filesize
*
* @copyright 2022 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 9.0.11
*/
const ARRAY = "array";
const BIT = "bit";
const BITS = "bits";
const BYTE = "byte";
const BYTES = "bytes";
const EMPTY = "";
const EXPONENT = "exponent";
const FUNCTION = "function";
const IEC = "iec";
const INVALID_NUMBER = "Invalid number";
const INVALID_ROUND = "Invalid rounding method";
const JEDEC = "jedec";
const OBJECT = "object";
const PERIOD = ".";
const ROUND = "round";
const S = "s";
const SI_KBIT = "kbit";
const SI_KBYTE = "kB";
const SPACE = " ";
const STRING = "string";
const ZERO = "0";
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"]
}
},
fullform: {
iec: ["", "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi", "yobi"],
jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"]
}
};
/**
* filesize
*
* @method filesize
* @param {Mixed} arg String, Int or Float to transform
* @param {Object} descriptor [Optional] Flags
* @return {String} Readable file size String
*/
function filesize (arg, {
bits = false,
pad = false,
base = -1,
round = 2,
locale = EMPTY,
localeOptions = {},
separator = EMPTY,
spacer = SPACE,
symbols = {},
standard = EMPTY,
output = STRING,
fullform = false,
fullforms = [],
exponent = -1,
roundingMethod = ROUND,
precision = 0
} = {}) {
let e = exponent,
num = Number(arg),
result = [],
val = 0,
u = EMPTY;
// Sync base & standard
if (base === -1 && standard.length === 0) {
base = 10;
standard = JEDEC;
} else if (base === -1 && standard.length > 0) {
standard = standard === IEC ? IEC : JEDEC;
base = standard === IEC ? 2 : 10;
} else {
base = base === 2 ? 2 : 10;
standard = base === 10 ? JEDEC : standard === JEDEC ? JEDEC : IEC;
}
const ceil = base === 10 ? 1000 : 1024,
full = fullform === true,
neg = num < 0,
roundingFunc = Math[roundingMethod];
if (isNaN(arg)) {
throw new TypeError(INVALID_NUMBER);
}
if (typeof roundingFunc !== FUNCTION) {
throw new TypeError(INVALID_ROUND);
}
// Flipping a negative number to determine the size
if (neg) {
num = -num;
}
// Determining the exponent
if (e === -1 || isNaN(e)) {
e = Math.floor(Math.log(num) / Math.log(ceil));
if (e < 0) {
e = 0;
}
}
// Exceeding supported length, time to reduce & multiply
if (e > 8) {
if (precision > 0) {
precision += 8 - e;
}
e = 8;
}
if (output === EXPONENT) {
return e;
}
// Zero is now a special case because bytes divide by 1
if (num === 0) {
result[0] = 0;
u = result[1] = strings.symbol[standard][bits ? BITS : BYTES][e];
} else {
val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));
if (bits) {
val = val * 8;
if (val >= ceil && e < 8) {
val = val / ceil;
e++;
}
}
const p = Math.pow(10, e > 0 ? round : 0);
result[0] = roundingFunc(val * p) / p;
if (result[0] === ceil && e < 8 && exponent === -1) {
result[0] = 1;
e++;
}
u = result[1] = base === 10 && e === 1 ? bits ? SI_KBIT : SI_KBYTE : strings.symbol[standard][bits ? BITS : BYTES][e];
}
// Decorating a 'diff'
if (neg) {
result[0] = -result[0];
}
// Setting optional precision
if (precision > 0) {
result[0] = result[0].toPrecision(precision);
}
// Applying custom symbol
result[1] = symbols[result[1]] || result[1];
if (locale === true) {
result[0] = result[0].toLocaleString();
} else if (locale.length > 0) {
result[0] = result[0].toLocaleString(locale, localeOptions);
} else if (separator.length > 0) {
result[0] = result[0].toString().replace(PERIOD, separator);
}
if (pad && Number.isInteger(result[0]) === false && round > 0) {
const x = separator || PERIOD,
tmp = result[0].toString().split(x),
s = tmp[1] || EMPTY,
l = s.length,
n = round - l;
result[0] = `${tmp[0]}${x}${s.padEnd(l + n, ZERO)}`;
}
if (full) {
result[1] = fullforms[e] ? fullforms[e] : strings.fullform[standard][e] + (bits ? BIT : BYTE) + (result[0] === 1 ? EMPTY : S);
}
// Returning Array, Object, or String (default)
return output === ARRAY ? result : output === OBJECT ? {
value: result[0],
symbol: result[1],
exponent: e,
unit: u
} : result.join(spacer);
}
// Partial application for functional programming
filesize.partial = opt => arg => filesize(arg, opt);
export { filesize as default };

View file

@ -0,0 +1,6 @@
/*!
2022 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 9.0.11
*/
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"]}};function i(i,{bits:e=!1,pad:o=!1,base:b=-1,round:n=2,locale:r="",localeOptions:a={},separator:l="",spacer:s=" ",symbols:c={},standard:p="",output:d="string",fullform:u=!1,fullforms:g=[],exponent:B=-1,roundingMethod:f="round",precision:h=0}={}){let y=B,m=Number(i),M=[],j=0,w="";-1===b&&0===p.length?(b=10,p="jedec"):-1===b&&p.length>0?b="iec"===(p="iec"===p?"iec":"jedec")?2:10:p=10===(b=2===b?2:10)||"jedec"===p?"jedec":"iec";const E=10===b?1e3:1024,x=!0===u,N=m<0,T=Math[f];if(isNaN(i))throw new TypeError("Invalid number");if("function"!=typeof T)throw new TypeError("Invalid rounding method");if(N&&(m=-m),(-1===y||isNaN(y))&&(y=Math.floor(Math.log(m)/Math.log(E)),y<0&&(y=0)),y>8&&(h>0&&(h+=8-y),y=8),"exponent"===d)return y;if(0===m)M[0]=0,w=M[1]=t.symbol[p][e?"bits":"bytes"][y];else{j=m/(2===b?Math.pow(2,10*y):Math.pow(1e3,y)),e&&(j*=8,j>=E&&y<8&&(j/=E,y++));const i=Math.pow(10,y>0?n:0);M[0]=T(j*i)/i,M[0]===E&&y<8&&-1===B&&(M[0]=1,y++),w=M[1]=10===b&&1===y?e?"kbit":"kB":t.symbol[p][e?"bits":"bytes"][y]}if(N&&(M[0]=-M[0]),h>0&&(M[0]=M[0].toPrecision(h)),M[1]=c[M[1]]||M[1],!0===r?M[0]=M[0].toLocaleString():r.length>0?M[0]=M[0].toLocaleString(r,a):l.length>0&&(M[0]=M[0].toString().replace(".",l)),o&&!1===Number.isInteger(M[0])&&n>0){const t=l||".",i=M[0].toString().split(t),e=i[1]||"",o=e.length,b=n-o;M[0]=`${i[0]}${t}${e.padEnd(o+b,"0")}`}return x&&(M[1]=g[y]?g[y]:t.fullform[p][y]+(e?"bit":"byte")+(1===M[0]?"":"s")),"array"===d?M:"object"===d?{value:M[0],symbol:M[1],exponent:y,unit:w}:M.join(s)}i.partial=t=>e=>i(e,t);export{i as default};
//# sourceMappingURL=filesize.esm.min.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,243 @@
/**
* filesize
*
* @copyright 2022 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 9.0.11
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.filesize = factory());
})(this, (function () { 'use strict';
function _typeof(obj) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, _typeof(obj);
}
var ARRAY = "array";
var BIT = "bit";
var BITS = "bits";
var BYTE = "byte";
var BYTES = "bytes";
var EMPTY = "";
var EXPONENT = "exponent";
var FUNCTION = "function";
var IEC = "iec";
var INVALID_NUMBER = "Invalid number";
var INVALID_ROUND = "Invalid rounding method";
var JEDEC = "jedec";
var OBJECT = "object";
var PERIOD = ".";
var ROUND = "round";
var S = "s";
var SI_KBIT = "kbit";
var SI_KBYTE = "kB";
var SPACE = " ";
var STRING = "string";
var ZERO = "0";
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"]
}
},
fullform: {
iec: ["", "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi", "yobi"],
jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"]
}
};
/**
* filesize
*
* @method filesize
* @param {Mixed} arg String, Int or Float to transform
* @param {Object} descriptor [Optional] Flags
* @return {String} Readable file size String
*/
function filesize(arg) {
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 ? -1 : _ref$base,
_ref$round = _ref.round,
round = _ref$round === void 0 ? 2 : _ref$round,
_ref$locale = _ref.locale,
locale = _ref$locale === void 0 ? EMPTY : _ref$locale,
_ref$localeOptions = _ref.localeOptions,
localeOptions = _ref$localeOptions === void 0 ? {} : _ref$localeOptions,
_ref$separator = _ref.separator,
separator = _ref$separator === void 0 ? EMPTY : _ref$separator,
_ref$spacer = _ref.spacer,
spacer = _ref$spacer === void 0 ? SPACE : _ref$spacer,
_ref$symbols = _ref.symbols,
symbols = _ref$symbols === void 0 ? {} : _ref$symbols,
_ref$standard = _ref.standard,
standard = _ref$standard === void 0 ? EMPTY : _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,
u = EMPTY; // Sync base & standard
if (base === -1 && standard.length === 0) {
base = 10;
standard = JEDEC;
} else if (base === -1 && standard.length > 0) {
standard = standard === IEC ? IEC : JEDEC;
base = standard === IEC ? 2 : 10;
} else {
base = base === 2 ? 2 : 10;
standard = base === 10 ? JEDEC : standard === JEDEC ? JEDEC : IEC;
}
var ceil = base === 10 ? 1000 : 1024,
full = fullform === true,
neg = num < 0,
roundingFunc = Math[roundingMethod];
if (isNaN(arg)) {
throw new TypeError(INVALID_NUMBER);
}
if (_typeof(roundingFunc) !== FUNCTION) {
throw new TypeError(INVALID_ROUND);
} // Flipping a negative number to determine the size
if (neg) {
num = -num;
} // Determining the exponent
if (e === -1 || isNaN(e)) {
e = Math.floor(Math.log(num) / Math.log(ceil));
if (e < 0) {
e = 0;
}
} // Exceeding supported length, time to reduce & multiply
if (e > 8) {
if (precision > 0) {
precision += 8 - e;
}
e = 8;
}
if (output === EXPONENT) {
return e;
} // Zero is now a special case because bytes divide by 1
if (num === 0) {
result[0] = 0;
u = result[1] = strings.symbol[standard][bits ? BITS : BYTES][e];
} else {
val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));
if (bits) {
val = val * 8;
if (val >= ceil && e < 8) {
val = val / ceil;
e++;
}
}
var p = Math.pow(10, e > 0 ? round : 0);
result[0] = roundingFunc(val * p) / p;
if (result[0] === ceil && e < 8 && exponent === -1) {
result[0] = 1;
e++;
}
u = result[1] = base === 10 && e === 1 ? bits ? SI_KBIT : SI_KBYTE : strings.symbol[standard][bits ? BITS : BYTES][e];
} // Decorating a 'diff'
if (neg) {
result[0] = -result[0];
} // Setting optional precision
if (precision > 0) {
result[0] = result[0].toPrecision(precision);
} // Applying custom symbol
result[1] = symbols[result[1]] || result[1];
if (locale === true) {
result[0] = result[0].toLocaleString();
} else if (locale.length > 0) {
result[0] = result[0].toLocaleString(locale, localeOptions);
} else if (separator.length > 0) {
result[0] = result[0].toString().replace(PERIOD, separator);
}
if (pad && Number.isInteger(result[0]) === false && round > 0) {
var x = separator || PERIOD,
tmp = result[0].toString().split(x),
s = tmp[1] || EMPTY,
l = s.length,
n = round - l;
result[0] = "".concat(tmp[0]).concat(x).concat(s.padEnd(l + n, ZERO));
}
if (full) {
result[1] = fullforms[e] ? fullforms[e] : strings.fullform[standard][e] + (bits ? BIT : BYTE) + (result[0] === 1 ? EMPTY : S);
} // Returning Array, Object, or String (default)
return output === ARRAY ? result : output === OBJECT ? {
value: result[0],
symbol: result[1],
exponent: e,
unit: u
} : result.join(spacer);
} // Partial application for functional programming
filesize.partial = function (opt) {
return function (arg) {
return filesize(arg, opt);
};
};
return filesize;
}));

View file

@ -0,0 +1,6 @@
/*!
2022 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 9.0.11
*/
!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";function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(i){return typeof i}:function(i){return i&&"function"==typeof Symbol&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},i(t)}var t="array",o="bits",e="byte",n="bytes",r="",b="exponent",l="function",a="iec",d="Invalid number",f="Invalid rounding method",u="jedec",s="object",c=".",p="round",y="kbit",m="string",v={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function g(g){var h=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},B=h.bits,M=void 0!==B&&B,S=h.pad,T=void 0!==S&&S,w=h.base,x=void 0===w?-1:w,E=h.round,j=void 0===E?2:E,N=h.locale,P=void 0===N?r:N,k=h.localeOptions,G=void 0===k?{}:k,K=h.separator,Y=void 0===K?r:K,Z=h.spacer,z=void 0===Z?" ":Z,I=h.symbols,L=void 0===I?{}:I,O=h.standard,q=void 0===O?r:O,A=h.output,C=void 0===A?m:A,D=h.fullform,F=void 0!==D&&D,H=h.fullforms,J=void 0===H?[]:H,Q=h.exponent,R=void 0===Q?-1:Q,U=h.roundingMethod,V=void 0===U?p:U,W=h.precision,X=void 0===W?0:W,$=R,_=Number(g),ii=[],ti=0,oi=r;-1===x&&0===q.length?(x=10,q=u):-1===x&&q.length>0?x=(q=q===a?a:u)===a?2:10:q=10===(x=2===x?2:10)||q===u?u:a;var ei=10===x?1e3:1024,ni=!0===F,ri=_<0,bi=Math[V];if(isNaN(g))throw new TypeError(d);if(i(bi)!==l)throw new TypeError(f);if(ri&&(_=-_),(-1===$||isNaN($))&&($=Math.floor(Math.log(_)/Math.log(ei)))<0&&($=0),$>8&&(X>0&&(X+=8-$),$=8),C===b)return $;if(0===_)ii[0]=0,oi=ii[1]=v.symbol[q][M?o:n][$];else{ti=_/(2===x?Math.pow(2,10*$):Math.pow(1e3,$)),M&&(ti*=8)>=ei&&$<8&&(ti/=ei,$++);var li=Math.pow(10,$>0?j:0);ii[0]=bi(ti*li)/li,ii[0]===ei&&$<8&&-1===R&&(ii[0]=1,$++),oi=ii[1]=10===x&&1===$?M?y:"kB":v.symbol[q][M?o:n][$]}if(ri&&(ii[0]=-ii[0]),X>0&&(ii[0]=ii[0].toPrecision(X)),ii[1]=L[ii[1]]||ii[1],!0===P?ii[0]=ii[0].toLocaleString():P.length>0?ii[0]=ii[0].toLocaleString(P,G):Y.length>0&&(ii[0]=ii[0].toString().replace(c,Y)),T&&!1===Number.isInteger(ii[0])&&j>0){var ai=Y||c,di=ii[0].toString().split(ai),fi=di[1]||r,ui=fi.length,si=j-ui;ii[0]="".concat(di[0]).concat(ai).concat(fi.padEnd(ui+si,"0"))}return ni&&(ii[1]=J[$]?J[$]:v.fullform[q][$]+(M?"bit":e)+(1===ii[0]?r:"s")),C===t?ii:C===s?{value:ii[0],symbol:ii[1],exponent:$,unit:oi}:ii.join(z)}return g.partial=function(i){return function(t){return g(t,i)}},g}));
//# sourceMappingURL=filesize.min.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,55 @@
{
"name": "filesize",
"description": "JavaScript library to generate a human readable String describing the file size",
"version": "9.0.11",
"homepage": "https://filesizejs.com",
"author": "Jason Mulligan <jason.mulligan@avoidwork.com>",
"repository": {
"type": "git",
"url": "git://github.com/avoidwork/filesize.js.git"
},
"bugs": {
"url": "https://github.com/avoidwork/filesize.js/issues"
},
"files": [
"lib",
"*.d.ts"
],
"license": "BSD-3-Clause",
"browser": "lib/filesize.min.js",
"main": "lib/filesize.js",
"module": "lib/filesize.esm.js",
"types": "filesize.d.ts",
"engines": {
"node": ">= 0.4.0"
},
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w",
"changelog": "auto-changelog -p",
"test": "npm run build && npm run lint && npm run test:unit && npm run test:type",
"test:unit": "nodeunit test/filesize_test.js",
"test:type": "tsc -p test",
"lint": "eslint test/*.js src/*.js"
},
"devDependencies": {
"@babel/core": "^7.18.5",
"@babel/preset-env": "^7.18.2",
"auto-changelog": "^2.4.0",
"eslint": "^8.17.0",
"nodeunit-x": "^0.15.0",
"rollup": "^2.75.6",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-terser": "^7.0.2",
"typescript": "^4.7.3"
},
"keywords": [
"file",
"filesize",
"size",
"readable",
"file system",
"bytes",
"diff"
]
}