Socket
Socket
Sign inDemoInstall

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 6.0.1 to 6.1.0

CHANGELOG.md

6

lib/filesize.es6.js
/**
* filesize
*
* @copyright 2019 Jason Mulligan <jason.mulligan@avoidwork.com>
* @copyright 2020 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 6.0.1
* @version 6.1.0
*/

@@ -144,3 +144,3 @@ (function (global) {

if (output === "object") {
return {value: result[0], symbol: result[1]};
return {value: result[0], symbol: result[1], exponent: e};
}

@@ -147,0 +147,0 @@

/*
2019 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 6.0.1
2020 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 6.1.0
*/

@@ -8,5 +8,5 @@ "use strict";/**

*
* @copyright 2019 Jason Mulligan <jason.mulligan@avoidwork.com>
* @copyright 2020 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 6.0.1
* @version 6.1.0
*/(function(a){/**

@@ -19,3 +19,3 @@ * filesize

* @return {String} Readable file size String
*/function c(a,c={}){var g=Math.pow,h=Math.floor,i=Math.log;let j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A=[],B=0;if(isNaN(a))throw new TypeError("Invalid number");return(l=!0===c.bits,v=!0===c.unix,k=c.base||2,u=void 0===c.round?v?1:2:c.round,p=void 0===c.locale?"":c.locale,q=c.localeOptions||{},w=void 0===c.separator?"":c.separator,x=void 0===c.spacer?v?"":" ":c.spacer,z=c.symbols||{},y=2===k?c.standard||"jedec":"jedec",t=c.output||"string",n=!0===c.fullform,o=c.fullforms instanceof Array?c.fullforms:[],j=void 0===c.exponent?-1:c.exponent,s=+a,r=0>s,m=2<k?1e3:1024,r&&(s=-s),(-1===j||isNaN(j))&&(j=h(i(s)/i(m)),0>j&&(j=0)),8<j&&(j=8),"exponent"===t)?j:(0===s?(A[0]=0,A[1]=v?"":b[y][l?"bits":"bytes"][j]):(B=s/(2===k?g(2,10*j):g(1e3,j)),l&&(B*=8,B>=m&&8>j&&(B/=m,j++)),A[0]=+B.toFixed(0<j?u:0),A[0]===m&&8>j&&void 0===c.exponent&&(A[0]=1,j++),A[1]=10===k&&1===j?l?"kb":"kB":b[y][l?"bits":"bytes"][j],v&&(A[1]="jedec"===y?A[1].charAt(0):0<j?A[1].replace(/B$/,""):A[1],d.test(A[1])&&(A[0]=h(A[0]),A[1]=""))),r&&(A[0]=-A[0]),A[1]=z[A[1]]||A[1],!0===p?A[0]=A[0].toLocaleString():0<p.length?A[0]=A[0].toLocaleString(p,q):0<w.length&&(A[0]=A[0].toString().replace(".",w)),"array"===t)?A:(n&&(A[1]=o[j]?o[j]:f[y][j]+(l?"bit":"byte")+(1===A[0]?"":"s")),"object"===t?{value:A[0],symbol:A[1]}:A.join(x));// Zero is now a special case because bytes divide by 1
*/function c(a,c={}){var g=Math.pow,h=Math.floor,i=Math.log;let j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A=[],B=0;if(isNaN(a))throw new TypeError("Invalid number");return(l=!0===c.bits,v=!0===c.unix,k=c.base||2,u=void 0===c.round?v?1:2:c.round,p=void 0===c.locale?"":c.locale,q=c.localeOptions||{},w=void 0===c.separator?"":c.separator,x=void 0===c.spacer?v?"":" ":c.spacer,z=c.symbols||{},y=2===k?c.standard||"jedec":"jedec",t=c.output||"string",n=!0===c.fullform,o=c.fullforms instanceof Array?c.fullforms:[],j=void 0===c.exponent?-1:c.exponent,s=+a,r=0>s,m=2<k?1e3:1024,r&&(s=-s),(-1===j||isNaN(j))&&(j=h(i(s)/i(m)),0>j&&(j=0)),8<j&&(j=8),"exponent"===t)?j:(0===s?(A[0]=0,A[1]=v?"":b[y][l?"bits":"bytes"][j]):(B=s/(2===k?g(2,10*j):g(1e3,j)),l&&(B*=8,B>=m&&8>j&&(B/=m,j++)),A[0]=+B.toFixed(0<j?u:0),A[0]===m&&8>j&&void 0===c.exponent&&(A[0]=1,j++),A[1]=10===k&&1===j?l?"kb":"kB":b[y][l?"bits":"bytes"][j],v&&(A[1]="jedec"===y?A[1].charAt(0):0<j?A[1].replace(/B$/,""):A[1],d.test(A[1])&&(A[0]=h(A[0]),A[1]=""))),r&&(A[0]=-A[0]),A[1]=z[A[1]]||A[1],!0===p?A[0]=A[0].toLocaleString():0<p.length?A[0]=A[0].toLocaleString(p,q):0<w.length&&(A[0]=A[0].toString().replace(".",w)),"array"===t)?A:(n&&(A[1]=o[j]?o[j]:f[y][j]+(l?"bit":"byte")+(1===A[0]?"":"s")),"object"===t?{value:A[0],symbol:A[1],exponent:j}:A.join(x));// Zero is now a special case because bytes divide by 1
// Returning Array, Object, or String (default)

@@ -22,0 +22,0 @@ }// Partial application for functional programming

@@ -6,5 +6,5 @@ "use strict";

*
* @copyright 2019 Jason Mulligan <jason.mulligan@avoidwork.com>
* @copyright 2020 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 6.0.1
* @version 6.1.0
*/

@@ -165,3 +165,4 @@ (function (global) {

value: result[0],
symbol: result[1]
symbol: result[1],
exponent: e
};

@@ -168,0 +169,0 @@ }

/*
2019 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 6.0.1
2020 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 6.1.0
*/
"use strict";!function(e){var x=/^(b|B)$/,M={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"]}},w={iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]};function t(e){var i,t,o,n,b,r,a,l,s,d,u,c,f,p,B,y=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},g=[],v=0,m=void 0,h=void 0;if(isNaN(e))throw new TypeError("Invalid number");return t=!0===y.bits,u=!0===y.unix,i=y.base||2,d=void 0!==y.round?y.round:u?1:2,r=void 0!==y.locale?y.locale:"",a=y.localeOptions||{},c=void 0!==y.separator?y.separator:"",f=void 0!==y.spacer?y.spacer:u?"":" ",B=y.symbols||{},p=2===i&&y.standard||"jedec",s=y.output||"string",n=!0===y.fullform,b=y.fullforms instanceof Array?y.fullforms:[],m=void 0!==y.exponent?y.exponent:-1,o=2<i?1e3:1024,(l=(h=Number(e))<0)&&(h=-h),(-1===m||isNaN(m))&&(m=Math.floor(Math.log(h)/Math.log(o)))<0&&(m=0),8<m&&(m=8),"exponent"===s?m:(0===h?(g[0]=0,g[1]=u?"":M[p][t?"bits":"bytes"][m]):(v=h/(2===i?Math.pow(2,10*m):Math.pow(1e3,m)),t&&o<=(v*=8)&&m<8&&(v/=o,m++),g[0]=Number(v.toFixed(0<m?d:0)),g[0]===o&&m<8&&void 0===y.exponent&&(g[0]=1,m++),g[1]=10===i&&1===m?t?"kb":"kB":M[p][t?"bits":"bytes"][m],u&&(g[1]="jedec"===p?g[1].charAt(0):0<m?g[1].replace(/B$/,""):g[1],x.test(g[1])&&(g[0]=Math.floor(g[0]),g[1]=""))),l&&(g[0]=-g[0]),g[1]=B[g[1]]||g[1],!0===r?g[0]=g[0].toLocaleString():0<r.length?g[0]=g[0].toLocaleString(r,a):0<c.length&&(g[0]=g[0].toString().replace(".",c)),"array"===s?g:(n&&(g[1]=b[m]?b[m]:w[p][m]+(t?"bit":"byte")+(1===g[0]?"":"s")),"object"===s?{value:g[0],symbol:g[1]}:g.join(f)))}t.partial=function(i){return function(e){return t(e,i)}},"undefined"!=typeof exports?module.exports=t:"function"==typeof define&&void 0!==define.amd?define(function(){return t}):e.filesize=t}("undefined"!=typeof window?window:global);
"use strict";!function(e){var x=/^(b|B)$/,M={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"]}},w={iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]};function t(e){var i,t,o,n,b,r,a,l,s,d,u,c,f,p,B,y=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},g=[],v=0,m=void 0,h=void 0;if(isNaN(e))throw new TypeError("Invalid number");return t=!0===y.bits,u=!0===y.unix,i=y.base||2,d=void 0!==y.round?y.round:u?1:2,r=void 0!==y.locale?y.locale:"",a=y.localeOptions||{},c=void 0!==y.separator?y.separator:"",f=void 0!==y.spacer?y.spacer:u?"":" ",B=y.symbols||{},p=2===i&&y.standard||"jedec",s=y.output||"string",n=!0===y.fullform,b=y.fullforms instanceof Array?y.fullforms:[],m=void 0!==y.exponent?y.exponent:-1,o=2<i?1e3:1024,(l=(h=Number(e))<0)&&(h=-h),(-1===m||isNaN(m))&&(m=Math.floor(Math.log(h)/Math.log(o)))<0&&(m=0),8<m&&(m=8),"exponent"===s?m:(0===h?(g[0]=0,g[1]=u?"":M[p][t?"bits":"bytes"][m]):(v=h/(2===i?Math.pow(2,10*m):Math.pow(1e3,m)),t&&o<=(v*=8)&&m<8&&(v/=o,m++),g[0]=Number(v.toFixed(0<m?d:0)),g[0]===o&&m<8&&void 0===y.exponent&&(g[0]=1,m++),g[1]=10===i&&1===m?t?"kb":"kB":M[p][t?"bits":"bytes"][m],u&&(g[1]="jedec"===p?g[1].charAt(0):0<m?g[1].replace(/B$/,""):g[1],x.test(g[1])&&(g[0]=Math.floor(g[0]),g[1]=""))),l&&(g[0]=-g[0]),g[1]=B[g[1]]||g[1],!0===r?g[0]=g[0].toLocaleString():0<r.length?g[0]=g[0].toLocaleString(r,a):0<c.length&&(g[0]=g[0].toString().replace(".",c)),"array"===s?g:(n&&(g[1]=b[m]?b[m]:w[p][m]+(t?"bit":"byte")+(1===g[0]?"":"s")),"object"===s?{value:g[0],symbol:g[1],exponent:m}:g.join(f)))}t.partial=function(i){return function(e){return t(e,i)}},"undefined"!=typeof exports?module.exports=t:"function"==typeof define&&void 0!==define.amd?define(function(){return t}):e.filesize=t}("undefined"!=typeof window?window:global);
//# sourceMappingURL=filesize.min.js.map
{
"name": "filesize",
"description": "JavaScript library to generate a human readable String describing the file size",
"version": "6.0.1",
"version": "6.1.0",
"homepage": "https://filesizejs.com",

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

"scripts": {
"changelog": "git log --date=short --tags --format=\"[%cd] %h%d %s - %cn (%ce)\" > CHANGELOG",
"changelog": "auto-changelog -p",
"test": "grunt test"
},
"devDependencies": {
"auto-changelog": "^1.16.2",
"babel-core": "^6.26.3",

@@ -38,3 +39,3 @@ "babel-preset-env": "^1.7.0",

"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-nodeunit": "^2.0.0",
"grunt-contrib-nodeunit": "^2.1.0",
"grunt-contrib-uglify": "^4.0.1",

@@ -41,0 +42,0 @@ "grunt-contrib-watch": "^1.1.0",

@@ -62,3 +62,3 @@ # filesize.js

filesize(265318, {output: "array"}); // [259.1, "KB"]
filesize(265318, {output: "object"}); // {value: 259.1, symbol: "KB"}
filesize(265318, {output: "object"}); // {value: 259.1, symbol: "KB", exponent: 1}
filesize(1, {symbols: {B: "Б"}}); // "1 Б"

@@ -65,0 +65,0 @@ filesize(1024); // "1 KB"

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