Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

filesize

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filesize - npm Package Compare versions

Comparing version 9.0.0 to 9.0.1

0

filesize.d.ts

@@ -0,0 +0,0 @@ // Type definitions for filesize 8.0.3

69

lib/filesize.es6.js

@@ -6,3 +6,3 @@ /**

* @license BSD-3-Clause
* @version 9.0.0
* @version 9.0.1
*/

@@ -15,19 +15,22 @@ (function (global, factory) {

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
};

@@ -43,6 +46,12 @@

*/
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];

@@ -53,22 +62,2 @@ if (isNaN(arg)) {

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

@@ -104,3 +93,3 @@ if (neg) {

result[0] = 0;
u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e];
u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e];
} else {

@@ -121,3 +110,3 @@ val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));

if (result[0] === ceil && e < 8 && descriptor.exponent === void 0) {
if (result[0] === ceil && e < 8 && exponent === -1) {
result[0] = 1;

@@ -127,3 +116,3 @@ e++;

u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e];
u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e];
}

@@ -163,3 +152,3 @@

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");
}

@@ -166,0 +155,0 @@

/*!
2022 Jason Mulligan <jason.mulligan@avoidwork.com>
@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

@@ -6,21 +6,24 @@ /**

* @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
};

@@ -36,6 +39,12 @@

*/
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];

@@ -46,22 +55,2 @@ if (isNaN(arg)) {

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

@@ -97,3 +86,3 @@ if (neg) {

result[0] = 0;
u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e];
u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e];
} else {

@@ -114,3 +103,3 @@ val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));

if (result[0] === ceil && e < 8 && descriptor.exponent === void 0) {
if (result[0] === ceil && e < 8 && exponent === -1) {
result[0] = 1;

@@ -120,3 +109,3 @@ e++;

u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e];
u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e];
}

@@ -156,3 +145,3 @@

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");
}

@@ -159,0 +148,0 @@

/*!
2022 Jason Mulligan <jason.mulligan@avoidwork.com>
@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

@@ -6,3 +6,3 @@ /**

* @license BSD-3-Clause
* @version 9.0.0
* @version 9.0.1
*/

@@ -15,19 +15,22 @@ (function (global, factory) {

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
};

@@ -44,49 +47,50 @@ /**

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

@@ -122,3 +126,3 @@ if (neg) {

result[0] = 0;
u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e];
u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e];
} else {

@@ -139,3 +143,3 @@ val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));

if (result[0] === ceil && e < 8 && descriptor.exponent === void 0) {
if (result[0] === ceil && e < 8 && exponent === -1) {
result[0] = 1;

@@ -145,3 +149,3 @@ e++;

u = result[1] = symbol[standard][bits ? "bits" : "bytes"][e];
u = result[1] = strings.symbol[standard][bits ? "bits" : "bytes"][e];
} // Decorating a 'diff'

@@ -180,3 +184,3 @@

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)

@@ -183,0 +187,0 @@

/*!
2022 Jason Mulligan <jason.mulligan@avoidwork.com>
@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
{
"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",

@@ -41,3 +41,3 @@ "author": "Jason Mulligan <jason.mulligan@avoidwork.com>",

"nodeunit-x": "^0.15.0",
"rollup": "^2.74.1",
"rollup": "^2.75.5",
"rollup-plugin-babel": "^4.4.0",

@@ -44,0 +44,0 @@ "rollup-plugin-terser": "^7.0.2",

@@ -0,0 +0,0 @@ # filesize.js

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc