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 1.7.7 to 1.7.8

10

lib/filesize.js

@@ -9,3 +9,3 @@ /**

* @module filesize
* @version 1.7.7
* @version 1.7.8
*/

@@ -57,3 +57,3 @@

if (bit.test(suffix)) suffix = suffix.toLowerCase();
suffix = suffix.slice(0, 1);
suffix = suffix.charAt(0);
z = regex.exec(result);

@@ -67,2 +67,8 @@ if (z !== null && z[1] !== undefined && zero.test(z[1])) result = parseInt(result, base);

// Zero
if (result === "") {
if (short) pos = 0;
result = Number(0).toFixed(pos) + suffix;
}
return (neg ? "-" : "") + result;

@@ -69,0 +75,0 @@ };

4

lib/filesize.min.js

@@ -9,4 +9,4 @@ /**

* @module filesize
* @version 1.7.7
* @version 1.7.8
*/
(function(e){"use strict";var t=function(e){var t=10,n,r,i,s,o,u,a,f,l,c,h,p,d;arguments[2]!==undefined?(o=arguments[1],f=arguments[2]):typeof arguments[1]=="boolean"?f=arguments[1]:o=arguments[1];if(isNaN(e)||o!==undefined&&isNaN(o))throw Error("Invalid arguments");f=f===!0,o=f?1:o===undefined?2:parseInt(o,t),s=Number(e),i=s<0,c=[["B",1],["Kb",128],["KB",1024],["Mb",131072],["MB",1049e3],["Gb",1342e5],["GB",1074e6],["Tb",1374e8],["TB",11e11],["Pb",1407e11],["PB",1126e12]],r=c.length,a="",u=/\.(.*)/,n=/b$/,d=/^0$/,i&&(s=-s);while(r--){l=c[r][1],h=c[r][0];if(s>=l){a=(s/l).toFixed(o),f&&(n.test(h)&&(h=h.toLowerCase()),h=h.slice(0,1),p=u.exec(a),p!==null&&p[1]!==undefined&&d.test(p[1])&&(a=parseInt(a,t))),a+=h;break}}return(i?"-":"")+a};switch(!0){case typeof exports!="undefined":module.exports=t;break;case typeof define=="function":define(function(){return t});break;default:e.filesize=t}})(this);
(function(e){"use strict";var t=function(e){var t=10,n,r,i,s,o,u,a,f,l,c,h,p,d;arguments[2]!==undefined?(o=arguments[1],f=arguments[2]):typeof arguments[1]=="boolean"?f=arguments[1]:o=arguments[1];if(isNaN(e)||o!==undefined&&isNaN(o))throw Error("Invalid arguments");f=f===!0,o=f?1:o===undefined?2:parseInt(o,t),s=Number(e),i=s<0,c=[["B",1],["Kb",128],["KB",1024],["Mb",131072],["MB",1049e3],["Gb",1342e5],["GB",1074e6],["Tb",1374e8],["TB",11e11],["Pb",1407e11],["PB",1126e12]],r=c.length,a="",u=/\.(.*)/,n=/b$/,d=/^0$/,i&&(s=-s);while(r--){l=c[r][1],h=c[r][0];if(s>=l){a=(s/l).toFixed(o),f&&(n.test(h)&&(h=h.toLowerCase()),h=h.charAt(0),p=u.exec(a),p!==null&&p[1]!==undefined&&d.test(p[1])&&(a=parseInt(a,t))),a+=h;break}}return a===""&&(f&&(o=0),a=Number(0).toFixed(o)+h),(i?"-":"")+a};switch(!0){case typeof exports!="undefined":module.exports=t;break;case typeof define=="function":define(function(){return t});break;default:e.filesize=t}})(this);
{
"name": "filesize",
"description": "JavaScript library to generate a human readable String describing the file size",
"version": "1.7.7",
"version": "1.7.8",
"homepage": "http://filesizejs.com",

@@ -6,0 +6,0 @@ "author": {

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

if (bit.test(suffix)) suffix = suffix.toLowerCase();
suffix = suffix.slice(0, 1);
suffix = suffix.charAt(0);
z = regex.exec(result);

@@ -55,2 +55,8 @@ if (z !== null && z[1] !== undefined && zero.test(z[1])) result = parseInt(result, base);

// Zero
if (result === "") {
if (short) pos = 0;
result = Number(0).toFixed(pos) + suffix;
}
return (neg ? "-" : "") + result;

@@ -57,0 +63,0 @@ };

@@ -11,6 +11,7 @@ var filesize = require("../lib/filesize.js");

this.byte = 1;
this.zero = 0;
done();
},
valid: function (test) {
test.expect(13);
test.expect(16);
test.equal(filesize(this.Kb), "3.91Kb", "Should match");

@@ -29,2 +30,5 @@ test.equal(filesize(this.Kb,true), "3.9k", "Should match");

test.equal(filesize(this.byte, true), "1B", "Should match");
test.equal(filesize(this.zero), "0.00B", "Should match");
test.equal(filesize(this.zero, 1), "0.0B", "Should match");
test.equal(filesize(this.zero, true), "0B", "Should match");
this.byte = 1;

@@ -31,0 +35,0 @@ test.done();

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