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

10

lib/filesize.js

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

* @module filesize
* @version 1.7.6
* @version 1.7.7
*/

@@ -26,3 +26,3 @@

var base = 10,
bit, byte, i, neg, num, pos, regex, result, short, size, sizes, suffix, z, zero;
bit, i, neg, num, pos, regex, result, short, size, sizes, suffix, z, zero;

@@ -41,3 +41,3 @@ if (arguments[2] !== undefined) {

neg = (num < 0);
sizes = [["B", 0], ["Kb", 128], ["KB", 1024], ["Mb", 131072], ["MB", "1.049e+6"], ["Gb", "1.342e+8"], ["GB", "1.074e+9"], ["Tb", "1.374e+11"], ["TB", "1.1e+12"], ["Pb", "1.407e+14"], ["PB", "1.126e+15"]];
sizes = [["B", 1], ["Kb", 128], ["KB", 1024], ["Mb", 131072], ["MB", 1.049e+6], ["Gb", 1.342e+8], ["GB", 1.074e+9], ["Tb", 1.374e+11], ["TB", 1.1e+12], ["Pb", 1.407e+14], ["PB", 1.126e+15]];
i = sizes.length;

@@ -47,3 +47,2 @@ result = "";

bit = /b$/;
byte = /^B$/;
zero = /^0$/;

@@ -57,5 +56,4 @@

suffix = sizes[i][0];
if (i > 3) size = Number(size);
if (num >= size) {
result = (byte.test(suffix) ? num : (num / size)).toFixed(pos);
result = (num / size).toFixed(pos);
if (short) {

@@ -62,0 +60,0 @@ if (bit.test(suffix)) suffix = suffix.toLowerCase();

4

lib/filesize.min.js

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

* @module filesize
* @version 1.7.6
* @version 1.7.7
*/
(function(e){"use strict";var t=function(e){var t=10,n,r,i,s,o,u,a,f,l,c,h,p,d,v;arguments[2]!==undefined?(u=arguments[1],l=arguments[2]):typeof arguments[1]=="boolean"?l=arguments[1]:u=arguments[1];if(isNaN(e)||u!==undefined&&isNaN(u))throw Error("Invalid arguments");l=l===!0,u=l?1:u===undefined?2:parseInt(u,t),o=Number(e),s=o<0,h=[["B",0],["Kb",128],["KB",1024],["Mb",131072],["MB","1.049e+6"],["Gb","1.342e+8"],["GB","1.074e+9"],["Tb","1.374e+11"],["TB","1.1e+12"],["Pb","1.407e+14"],["PB","1.126e+15"]],i=h.length,f="",a=/\.(.*)/,n=/b$/,r=/^B$/,v=/^0$/,s&&(o=-o);while(i--){c=h[i][1],p=h[i][0],i>3&&(c=Number(c));if(o>=c){f=(r.test(p)?o:o/c).toFixed(u),l&&(n.test(p)&&(p=p.toLowerCase()),p=p.slice(0,1),d=a.exec(f),d!==null&&d[1]!==undefined&&v.test(d[1])&&(f=parseInt(f,t))),f+=p;break}}return(s?"-":"")+f};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.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);
{
"name": "filesize",
"description": "JavaScript library to generate a human readable String describing the file size",
"version": "1.7.6",
"version": "1.7.7",
"homepage": "http://filesizejs.com",

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

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

var base = 10,
bit, byte, i, neg, num, pos, regex, result, short, size, sizes, suffix, z, zero;
bit, i, neg, num, pos, regex, result, short, size, sizes, suffix, z, zero;

@@ -29,3 +29,3 @@ if (arguments[2] !== undefined) {

neg = (num < 0);
sizes = [["B", 0], ["Kb", 128], ["KB", 1024], ["Mb", 131072], ["MB", "1.049e+6"], ["Gb", "1.342e+8"], ["GB", "1.074e+9"], ["Tb", "1.374e+11"], ["TB", "1.1e+12"], ["Pb", "1.407e+14"], ["PB", "1.126e+15"]];
sizes = [["B", 1], ["Kb", 128], ["KB", 1024], ["Mb", 131072], ["MB", 1.049e+6], ["Gb", 1.342e+8], ["GB", 1.074e+9], ["Tb", 1.374e+11], ["TB", 1.1e+12], ["Pb", 1.407e+14], ["PB", 1.126e+15]];
i = sizes.length;

@@ -35,3 +35,2 @@ result = "";

bit = /b$/;
byte = /^B$/;
zero = /^0$/;

@@ -45,5 +44,4 @@

suffix = sizes[i][0];
if (i > 3) size = Number(size);
if (num >= size) {
result = (byte.test(suffix) ? num : (num / size)).toFixed(pos);
result = (num / size).toFixed(pos);
if (short) {

@@ -50,0 +48,0 @@ if (bit.test(suffix)) suffix = suffix.toLowerCase();

@@ -10,16 +10,21 @@ var filesize = require("../lib/filesize.js");

this.neg = -1024;
this.byte = 1;
done();
},
valid: function (test) {
test.expect(10);
test.equal(filesize(this.Kb), "3.91Kb", "Should match");
test.equal(filesize(this.Kb,true), "3.9k", "Should match");
test.equal(filesize(this.num), "1.00KB", "Should match");
test.equal(filesize(this.str), "1.00KB", "Should match");
test.equal(filesize(this.num, 1), "1.0KB", "Should match");
test.equal(filesize(this.str, 1), "1.0KB", "Should match");
test.equal(filesize(this.num, true), "1K", "Should match");
test.equal(filesize(this.str, true), "1K", "Should match");
test.equal(filesize(this.neg), "-1.00KB", "Should match");
test.equal(filesize(this.neg, true), "-1K", "Should match");
test.expect(13);
test.equal(filesize(this.Kb), "3.91Kb", "Should match");
test.equal(filesize(this.Kb,true), "3.9k", "Should match");
test.equal(filesize(this.num), "1.00KB", "Should match");
test.equal(filesize(this.str), "1.00KB", "Should match");
test.equal(filesize(this.num, 1), "1.0KB", "Should match");
test.equal(filesize(this.str, 1), "1.0KB", "Should match");
test.equal(filesize(this.num, true), "1K", "Should match");
test.equal(filesize(this.str, true), "1K", "Should match");
test.equal(filesize(this.neg), "-1.00KB", "Should match");
test.equal(filesize(this.neg, true), "-1K", "Should match");
test.equal(filesize(this.byte), "1.00B", "Should match");
test.equal(filesize(this.byte, 1), "1.0B", "Should match");
test.equal(filesize(this.byte, true), "1B", "Should match");
this.byte = 1;
test.done();

@@ -26,0 +31,0 @@ },

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