Socket
Socket
Sign inDemoInstall

filesize

Package Overview
Dependencies
0
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.3.0 to 6.4.0

14

lib/filesize.es6.js

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

* @license BSD-3-Clause
* @version 6.3.0
* @version 6.4.0
*/

@@ -46,3 +46,3 @@ (function (global, factory) {

val = 0,
e, base, bits, ceil, full, fullforms, locale, localeOptions, neg, num, output, pad, round, u, unix, separator, spacer, standard, symbols, roundingFunc;
e, base, bits, ceil, full, fullforms, locale, localeOptions, neg, num, output, pad, round, u, unix, separator, spacer, standard, symbols, roundingFunc, precision;

@@ -72,2 +72,3 @@ if (isNaN(arg)) {

ceil = base > 2 ? 1000 : 1024;
precision = isNaN(descriptor.precision) === false ? parseInt(descriptor.precision, 10) : 0;

@@ -90,2 +91,6 @@ // Flipping a negative number to determine the size

if (e > 8) {
if (precision > 0) {
precision += 8 - e;
}
e = 8;

@@ -139,2 +144,7 @@ }

// Setting optional precision
if (precision > 0) {
result[0] = result[0].toPrecision(precision);
}
// Applying custom symbol

@@ -141,0 +151,0 @@ result[1] = symbols[result[1]] || result[1];

4

lib/filesize.es6.min.js
/*!
2020 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 6.3.0
@version 6.4.0
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).filesize=t()}(this,(function(){"use strict";const e=/^(b|B)$/,t={iec:{bits:["b","Kib","Mib","Gib","Tib","Pib","Eib","Zib","Yib"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["b","Kb","Mb","Gb","Tb","Pb","Eb","Zb","Yb"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},i={iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]},o={floor:Math.floor,ceil:Math.ceil};function n(n,a={}){let b,r,l,s,d,f,c,p,u,B,h,g,y,M,m,x,v,j,T,E,N=[],w=0;if(isNaN(n))throw new TypeError("Invalid number");if(l=!0===a.bits,m=!0===a.unix,g=!0===a.pad,r=a.base||2,y=void 0!==a.round?a.round:m?1:2,c=void 0!==a.locale?a.locale:"",p=a.localeOptions||{},x=void 0!==a.separator?a.separator:"",v=void 0!==a.spacer?a.spacer:m?"":" ",T=a.symbols||{},j=2===r&&a.standard||"jedec",h=a.output||"string",d=!0===a.fullform,f=a.fullforms instanceof Array?a.fullforms:[],b=void 0!==a.exponent?a.exponent:-1,E=o[a.roundingMethod]||Math.round,B=Number(n),u=B<0,s=r>2?1e3:1024,u&&(B=-B),(-1===b||isNaN(b))&&(b=Math.floor(Math.log(B)/Math.log(s)),b<0&&(b=0)),b>8&&(b=8),"exponent"===h)return b;if(0===B)N[0]=0,M=N[1]=m?"":t[j][l?"bits":"bytes"][b];else{w=B/(2===r?Math.pow(2,10*b):Math.pow(1e3,b)),l&&(w*=8,w>=s&&b<8&&(w/=s,b++));const i=Math.pow(10,b>0?y:0);N[0]=E(w*i)/i,N[0]===s&&b<8&&void 0===a.exponent&&(N[0]=1,b++),M=N[1]=10===r&&1===b?l?"kb":"kB":t[j][l?"bits":"bytes"][b],m&&(N[1]="jedec"===j?N[1].charAt(0):b>0?N[1].replace(/B$/,""):N[1],e.test(N[1])&&(N[0]=Math.floor(N[0]),N[1]=""))}if(u&&(N[0]=-N[0]),N[1]=T[N[1]]||N[1],!0===c?N[0]=N[0].toLocaleString():c.length>0?N[0]=N[0].toLocaleString(c,p):x.length>0&&(N[0]=N[0].toString().replace(".",x)),g&&!1===Number.isInteger(N[0])&&y>0){const e=x||".",t=N[0].toString().split(e),i=t[1]||"",o=i.length,n=y-o;N[0]=`${t[0]}${e}${i.padEnd(o+n,"0")}`}return d&&(N[1]=f[b]?f[b]:i[j][b]+(l?"bit":"byte")+(1===N[0]?"":"s")),"array"===h?N:"object"===h?{value:N[0],symbol:N[1],exponent:b,unit:M}:N.join(v)}return n.partial=e=>t=>n(t,e),n}));
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(e="undefined"!=typeof globalThis?globalThis:e||self).filesize=i()}(this,(function(){"use strict";const e=/^(b|B)$/,i={iec:{bits:["b","Kib","Mib","Gib","Tib","Pib","Eib","Zib","Yib"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["b","Kb","Mb","Gb","Tb","Pb","Eb","Zb","Yb"],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"]},o={floor:Math.floor,ceil:Math.ceil};function n(n,r={}){let a,b,s,l,c,p,d,f,u,B,h,g,y,M,m,x,v,N,j,T,E,w=[],P=0;if(isNaN(n))throw new TypeError("Invalid number");if(s=!0===r.bits,m=!0===r.unix,g=!0===r.pad,b=r.base||2,y=void 0!==r.round?r.round:m?1:2,d=void 0!==r.locale?r.locale:"",f=r.localeOptions||{},x=void 0!==r.separator?r.separator:"",v=void 0!==r.spacer?r.spacer:m?"":" ",j=r.symbols||{},N=2===b&&r.standard||"jedec",h=r.output||"string",c=!0===r.fullform,p=r.fullforms instanceof Array?r.fullforms:[],a=void 0!==r.exponent?r.exponent:-1,T=o[r.roundingMethod]||Math.round,B=Number(n),u=B<0,l=b>2?1e3:1024,E=!1===isNaN(r.precision)?parseInt(r.precision,10):0,u&&(B=-B),(-1===a||isNaN(a))&&(a=Math.floor(Math.log(B)/Math.log(l)),a<0&&(a=0)),a>8&&(E>0&&(E+=8-a),a=8),"exponent"===h)return a;if(0===B)w[0]=0,M=w[1]=m?"":i[N][s?"bits":"bytes"][a];else{P=B/(2===b?Math.pow(2,10*a):Math.pow(1e3,a)),s&&(P*=8,P>=l&&a<8&&(P/=l,a++));const t=Math.pow(10,a>0?y:0);w[0]=T(P*t)/t,w[0]===l&&a<8&&void 0===r.exponent&&(w[0]=1,a++),M=w[1]=10===b&&1===a?s?"kb":"kB":i[N][s?"bits":"bytes"][a],m&&(w[1]="jedec"===N?w[1].charAt(0):a>0?w[1].replace(/B$/,""):w[1],e.test(w[1])&&(w[0]=Math.floor(w[0]),w[1]=""))}if(u&&(w[0]=-w[0]),E>0&&(w[0]=w[0].toPrecision(E)),w[1]=j[w[1]]||w[1],!0===d?w[0]=w[0].toLocaleString():d.length>0?w[0]=w[0].toLocaleString(d,f):x.length>0&&(w[0]=w[0].toString().replace(".",x)),g&&!1===Number.isInteger(w[0])&&y>0){const e=x||".",i=w[0].toString().split(e),t=i[1]||"",o=t.length,n=y-o;w[0]=`${i[0]}${e}${t.padEnd(o+n,"0")}`}return c&&(w[1]=p[a]?p[a]:t[N][a]+(s?"bit":"byte")+(1===w[0]?"":"s")),"array"===h?w:"object"===h?{value:w[0],symbol:w[1],exponent:a,unit:M}:w.join(v)}return n.partial=e=>i=>n(i,e),n}));
//# sourceMappingURL=filesize.es6.min.js.map

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

* @license BSD-3-Clause
* @version 6.3.0
* @version 6.4.0
*/

@@ -66,3 +66,4 @@ (function (global, factory) {

symbols,
roundingFunc;
roundingFunc,
precision;

@@ -91,3 +92,4 @@ if (isNaN(arg)) {

neg = num < 0;
ceil = base > 2 ? 1000 : 1024; // Flipping a negative number to determine the size
ceil = base > 2 ? 1000 : 1024;
precision = isNaN(descriptor.precision) === false ? parseInt(descriptor.precision, 10) : 0; // Flipping a negative number to determine the size

@@ -109,2 +111,6 @@ if (neg) {

if (e > 8) {
if (precision > 0) {
precision += 8 - e;
}
e = 8;

@@ -156,2 +162,7 @@ }

result[0] = -result[0];
} // Setting optional precision
if (precision > 0) {
result[0] = result[0].toPrecision(precision);
} // Applying custom symbol

@@ -158,0 +169,0 @@

/*!
2020 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 6.3.0
@version 6.4.0
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).filesize=t()}(this,(function(){"use strict";var e=/^(b|B)$/,t={iec:{bits:["b","Kib","Mib","Gib","Tib","Pib","Eib","Zib","Yib"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["b","Kb","Mb","Gb","Tb","Pb","Eb","Zb","Yb"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},i={iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]},o={floor:Math.floor,ceil:Math.ceil};function n(n){var r,a,b,l,s,c,d,f,u,p,B,h,g,y,M,m,v,x,j,T,E=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},N=[],w=0;if(isNaN(n))throw new TypeError("Invalid number");if(b=!0===E.bits,M=!0===E.unix,h=!0===E.pad,a=E.base||2,g=void 0!==E.round?E.round:M?1:2,d=void 0!==E.locale?E.locale:"",f=E.localeOptions||{},m=void 0!==E.separator?E.separator:"",v=void 0!==E.spacer?E.spacer:M?"":" ",j=E.symbols||{},x=2===a&&E.standard||"jedec",B=E.output||"string",s=!0===E.fullform,c=E.fullforms instanceof Array?E.fullforms:[],r=void 0!==E.exponent?E.exponent:-1,T=o[E.roundingMethod]||Math.round,l=a>2?1e3:1024,(u=(p=Number(n))<0)&&(p=-p),(-1===r||isNaN(r))&&(r=Math.floor(Math.log(p)/Math.log(l)))<0&&(r=0),r>8&&(r=8),"exponent"===B)return r;if(0===p)N[0]=0,y=N[1]=M?"":t[x][b?"bits":"bytes"][r];else{w=p/(2===a?Math.pow(2,10*r):Math.pow(1e3,r)),b&&(w*=8)>=l&&r<8&&(w/=l,r++);var k=Math.pow(10,r>0?g:0);N[0]=T(w*k)/k,N[0]===l&&r<8&&void 0===E.exponent&&(N[0]=1,r++),y=N[1]=10===a&&1===r?b?"kb":"kB":t[x][b?"bits":"bytes"][r],M&&(N[1]="jedec"===x?N[1].charAt(0):r>0?N[1].replace(/B$/,""):N[1],e.test(N[1])&&(N[0]=Math.floor(N[0]),N[1]=""))}if(u&&(N[0]=-N[0]),N[1]=j[N[1]]||N[1],!0===d?N[0]=N[0].toLocaleString():d.length>0?N[0]=N[0].toLocaleString(d,f):m.length>0&&(N[0]=N[0].toString().replace(".",m)),h&&!1===Number.isInteger(N[0])&&g>0){var G=m||".",K=N[0].toString().split(G),P=K[1]||"",S=P.length,Y=g-S;N[0]="".concat(K[0]).concat(G).concat(P.padEnd(S+Y,"0"))}return s&&(N[1]=c[r]?c[r]:i[x][r]+(b?"bit":"byte")+(1===N[0]?"":"s")),"array"===B?N:"object"===B?{value:N[0],symbol:N[1],exponent:r,unit:y}:N.join(v)}return n.partial=function(e){return function(t){return n(t,e)}},n}));
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(e="undefined"!=typeof globalThis?globalThis:e||self).filesize=i()}(this,(function(){"use strict";var e=/^(b|B)$/,i={iec:{bits:["b","Kib","Mib","Gib","Tib","Pib","Eib","Zib","Yib"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["b","Kb","Mb","Gb","Tb","Pb","Eb","Zb","Yb"],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"]},o={floor:Math.floor,ceil:Math.ceil};function n(n){var r,a,b,l,s,c,d,f,p,u,B,h,g,y,M,m,v,x,N,j,T,E=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},w=[],P=0;if(isNaN(n))throw new TypeError("Invalid number");if(b=!0===E.bits,M=!0===E.unix,h=!0===E.pad,a=E.base||2,g=void 0!==E.round?E.round:M?1:2,d=void 0!==E.locale?E.locale:"",f=E.localeOptions||{},m=void 0!==E.separator?E.separator:"",v=void 0!==E.spacer?E.spacer:M?"":" ",N=E.symbols||{},x=2===a&&E.standard||"jedec",B=E.output||"string",s=!0===E.fullform,c=E.fullforms instanceof Array?E.fullforms:[],r=void 0!==E.exponent?E.exponent:-1,j=o[E.roundingMethod]||Math.round,p=(u=Number(n))<0,l=a>2?1e3:1024,T=!1===isNaN(E.precision)?parseInt(E.precision,10):0,p&&(u=-u),(-1===r||isNaN(r))&&(r=Math.floor(Math.log(u)/Math.log(l)))<0&&(r=0),r>8&&(T>0&&(T+=8-r),r=8),"exponent"===B)return r;if(0===u)w[0]=0,y=w[1]=M?"":i[x][b?"bits":"bytes"][r];else{P=u/(2===a?Math.pow(2,10*r):Math.pow(1e3,r)),b&&(P*=8)>=l&&r<8&&(P/=l,r++);var k=Math.pow(10,r>0?g:0);w[0]=j(P*k)/k,w[0]===l&&r<8&&void 0===E.exponent&&(w[0]=1,r++),y=w[1]=10===a&&1===r?b?"kb":"kB":i[x][b?"bits":"bytes"][r],M&&(w[1]="jedec"===x?w[1].charAt(0):r>0?w[1].replace(/B$/,""):w[1],e.test(w[1])&&(w[0]=Math.floor(w[0]),w[1]=""))}if(p&&(w[0]=-w[0]),T>0&&(w[0]=w[0].toPrecision(T)),w[1]=N[w[1]]||w[1],!0===d?w[0]=w[0].toLocaleString():d.length>0?w[0]=w[0].toLocaleString(d,f):m.length>0&&(w[0]=w[0].toString().replace(".",m)),h&&!1===Number.isInteger(w[0])&&g>0){var G=m||".",K=w[0].toString().split(G),S=K[1]||"",Y=S.length,Z=g-Y;w[0]="".concat(K[0]).concat(G).concat(S.padEnd(Y+Z,"0"))}return s&&(w[1]=c[r]?c[r]:t[x][r]+(b?"bit":"byte")+(1===w[0]?"":"s")),"array"===B?w:"object"===B?{value:w[0],symbol:w[1],exponent:r,unit:y}:w.join(v)}return n.partial=function(e){return function(i){return n(i,e)}},n}));
//# sourceMappingURL=filesize.min.js.map
{
"name": "filesize",
"description": "JavaScript library to generate a human readable String describing the file size",
"version": "6.3.0",
"version": "6.4.0",
"homepage": "https://filesizejs.com",

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

"devDependencies": {
"@babel/core": "^7.13.15",
"@babel/preset-env": "^7.13.15",
"auto-changelog": "^2.2.1",
"eslint": "^7.24.0",
"@babel/core": "^7.14.6",
"@babel/preset-env": "^7.14.7",
"auto-changelog": "^2.3.0",
"eslint": "^7.29.0",
"nodeunit-x": "^0.14.0",
"rollup": "^2.45.2",
"rollup": "^2.52.3",
"rollup-plugin-babel": "^4.4.0",

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

@@ -38,5 +38,11 @@ # filesize.js

### 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

@@ -57,5 +63,2 @@ _*(string)*_ Decimal separator character, default is `.`

### roundingMethod
_*(string)*_ Rounding method, can be `round`, `floor`, or `ceil`, default is `round`
## Examples

@@ -62,0 +65,0 @@

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc