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.2.6 to 6.3.0

18

CHANGELOG.md

@@ -7,4 +7,20 @@ ### Changelog

#### [6.2.5](https://github.com//avoidwork/filesize.js.git/compare/6.2.5...6.2.5)
#### [6.3.0](https://github.com//avoidwork/filesize.js.git/compare/6.3.0...6.3.0)
#### [6.3.0](https://github.com//avoidwork/filesize.js.git/compare/6.2.6...6.3.0)
> 21 April 2021
- [feature suggestion] add roundingMethod option [`#131`](https://github.com//avoidwork/filesize.js.git/pull/131)
- add roundingMethod option [`f2acf64`](https://github.com//avoidwork/filesize.js.git/commit/f2acf64d9ec91d330f497aa64a1e29ae243d7b82)
- Version bump to release `roundingMethod` option [`26735f6`](https://github.com//avoidwork/filesize.js.git/commit/26735f614a7a3f768ec3286966802a405dc3ed80)
- Updating CHANGELOG.md [`e1448a6`](https://github.com//avoidwork/filesize.js.git/commit/e1448a68fb107b3de924c10c8635edb6cbdd7969)
#### [6.2.6](https://github.com//avoidwork/filesize.js.git/compare/6.2.5...6.2.6)
> 19 April 2021
- Fixing missing `unit` on `object` output when input is `0` [`72c5736`](https://github.com//avoidwork/filesize.js.git/commit/72c5736d5b8d9a9d27b5bcc83fef0bdc4732d86f)
- Updating CHANGELOG.md [`75c2445`](https://github.com//avoidwork/filesize.js.git/commit/75c2445a5ff60bab62ca403ea5b85cd4200eade9)
#### [6.2.5](https://github.com//avoidwork/filesize.js.git/compare/6.2.4...6.2.5)

@@ -11,0 +27,0 @@

@@ -97,2 +97,6 @@ // Type definitions for filesize 6.0.1

unix?: boolean;
/**
* Rounding method, can be round, floor, or ceil, default is round
*/
roundingMethod?: "round" | "floor" | "ceil";
}

@@ -99,0 +103,0 @@

12

lib/filesize.es6.js

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

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

@@ -29,2 +29,6 @@ (function (global, factory) {

jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"]
},
roundingFuncs = {
floor: Math.floor,
ceil: Math.ceil
};

@@ -43,3 +47,3 @@

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

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

e = descriptor.exponent !== void 0 ? descriptor.exponent : -1;
roundingFunc = roundingFuncs[descriptor.roundingMethod] || Math.round;
num = Number(arg);

@@ -109,3 +114,4 @@ neg = num < 0;

result[0] = Number(val.toFixed(e > 0 ? round : 0));
const p = Math.pow(10, e > 0 ? round : 0);
result[0] = roundingFunc(val * p) / p;

@@ -112,0 +118,0 @@ if (result[0] === ceil && e < 8 && descriptor.exponent === void 0) {

/*!
2020 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 6.2.6
@version 6.3.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"]};function o(o,n={}){let b,r,a,s,l,d,p,f,c,u,B,g,y,h,m,x,M,v,j,N=[],T=0;if(isNaN(o))throw new TypeError("Invalid number");if(a=!0===n.bits,m=!0===n.unix,g=!0===n.pad,r=n.base||2,y=void 0!==n.round?n.round:m?1:2,p=void 0!==n.locale?n.locale:"",f=n.localeOptions||{},x=void 0!==n.separator?n.separator:"",M=void 0!==n.spacer?n.spacer:m?"":" ",j=n.symbols||{},v=2===r&&n.standard||"jedec",B=n.output||"string",l=!0===n.fullform,d=n.fullforms instanceof Array?n.fullforms:[],b=void 0!==n.exponent?n.exponent:-1,u=Number(o),c=u<0,s=r>2?1e3:1024,c&&(u=-u),(-1===b||isNaN(b))&&(b=Math.floor(Math.log(u)/Math.log(s)),b<0&&(b=0)),b>8&&(b=8),"exponent"===B)return b;if(0===u?(N[0]=0,h=N[1]=m?"":t[v][a?"bits":"bytes"][b]):(T=u/(2===r?Math.pow(2,10*b):Math.pow(1e3,b)),a&&(T*=8,T>=s&&b<8&&(T/=s,b++)),N[0]=Number(T.toFixed(b>0?y:0)),N[0]===s&&b<8&&void 0===n.exponent&&(N[0]=1,b++),h=N[1]=10===r&&1===b?a?"kb":"kB":t[v][a?"bits":"bytes"][b],m&&(N[1]="jedec"===v?N[1].charAt(0):b>0?N[1].replace(/B$/,""):N[1],e.test(N[1])&&(N[0]=Math.floor(N[0]),N[1]=""))),c&&(N[0]=-N[0]),N[1]=j[N[1]]||N[1],!0===p?N[0]=N[0].toLocaleString():p.length>0?N[0]=N[0].toLocaleString(p,f):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 l&&(N[1]=d[b]?d[b]:i[v][b]+(a?"bit":"byte")+(1===N[0]?"":"s")),"array"===B?N:"object"===B?{value:N[0],symbol:N[1],exponent:b,unit:h}:N.join(M)}return o.partial=e=>t=>o(t,e),o}));
!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}));
//# sourceMappingURL=filesize.es6.min.js.map

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

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

@@ -29,2 +29,6 @@ (function (global, factory) {

jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"]
},
roundingFuncs = {
floor: Math.floor,
ceil: Math.ceil
};

@@ -62,3 +66,4 @@ /**

standard,
symbols;
symbols,
roundingFunc;

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

e = descriptor.exponent !== void 0 ? descriptor.exponent : -1;
roundingFunc = roundingFuncs[descriptor.roundingMethod] || Math.round;
num = Number(arg);

@@ -127,3 +133,4 @@ neg = num < 0;

result[0] = Number(val.toFixed(e > 0 ? round : 0));
var p = Math.pow(10, e > 0 ? round : 0);
result[0] = roundingFunc(val * p) / p;

@@ -130,0 +137,0 @@ if (result[0] === ceil && e < 8 && descriptor.exponent === void 0) {

/*!
2020 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 6.2.6
@version 6.3.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"]};function o(o){var n,r,a,b,l,s,c,d,u,f,p,B,g,y,h,m,v,x,M,j=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},N=[],T=0;if(isNaN(o))throw new TypeError("Invalid number");if(a=!0===j.bits,h=!0===j.unix,B=!0===j.pad,r=j.base||2,g=void 0!==j.round?j.round:h?1:2,c=void 0!==j.locale?j.locale:"",d=j.localeOptions||{},m=void 0!==j.separator?j.separator:"",v=void 0!==j.spacer?j.spacer:h?"":" ",M=j.symbols||{},x=2===r&&j.standard||"jedec",p=j.output||"string",l=!0===j.fullform,s=j.fullforms instanceof Array?j.fullforms:[],n=void 0!==j.exponent?j.exponent:-1,b=r>2?1e3:1024,(u=(f=Number(o))<0)&&(f=-f),(-1===n||isNaN(n))&&(n=Math.floor(Math.log(f)/Math.log(b)))<0&&(n=0),n>8&&(n=8),"exponent"===p)return n;if(0===f?(N[0]=0,y=N[1]=h?"":t[x][a?"bits":"bytes"][n]):(T=f/(2===r?Math.pow(2,10*n):Math.pow(1e3,n)),a&&(T*=8)>=b&&n<8&&(T/=b,n++),N[0]=Number(T.toFixed(n>0?g:0)),N[0]===b&&n<8&&void 0===j.exponent&&(N[0]=1,n++),y=N[1]=10===r&&1===n?a?"kb":"kB":t[x][a?"bits":"bytes"][n],h&&(N[1]="jedec"===x?N[1].charAt(0):n>0?N[1].replace(/B$/,""):N[1],e.test(N[1])&&(N[0]=Math.floor(N[0]),N[1]=""))),u&&(N[0]=-N[0]),N[1]=M[N[1]]||N[1],!0===c?N[0]=N[0].toLocaleString():c.length>0?N[0]=N[0].toLocaleString(c,d):m.length>0&&(N[0]=N[0].toString().replace(".",m)),B&&!1===Number.isInteger(N[0])&&g>0){var E=m||".",k=N[0].toString().split(E),w=k[1]||"",G=w.length,K=g-G;N[0]="".concat(k[0]).concat(E).concat(w.padEnd(G+K,"0"))}return l&&(N[1]=s[n]?s[n]:i[x][n]+(a?"bit":"byte")+(1===N[0]?"":"s")),"array"===p?N:"object"===p?{value:N[0],symbol:N[1],exponent:n,unit:y}:N.join(v)}return o.partial=function(e){return function(t){return o(t,e)}},o}));
!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}));
//# sourceMappingURL=filesize.min.js.map
{
"name": "filesize",
"description": "JavaScript library to generate a human readable String describing the file size",
"version": "6.2.6",
"version": "6.3.0",
"homepage": "https://filesizejs.com",

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

@@ -56,2 +56,5 @@ # filesize.js

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

@@ -58,0 +61,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