Skip to content

Commit cf2c698

Browse files
committed
Removing unnecessary ops, making the AMD loading anonymous, updated docblock
1 parent a07019c commit cf2c698

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

debug/filesize.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@
3131
* Transforms a file size Number into a readable String
3232
*
3333
* @author Jason Mulligan <[email protected]>
34+
* @link http://filesizejs.com
3435
* @module filesize
35-
* @version 1.6.4
36+
* @version 1.6.5
3637
*
3738
* @param {Mixed} arg String, Int or Float to transform
3839
* @param {Number} pos [Optional] Position to round to, defaults to 2 if short is ommitted
3940
* @param {Boolean} short [Optional] Shorthand output, similar to "ls -lh", overrides pos to 1
40-
* @return {String} Readable file size String
41+
* @return {String} Readable file size String
4142
*/
4243
(function (global) {
4344
"use strict";
@@ -56,15 +57,14 @@
5657
short = (short === true);
5758
pos = short ? 1 : (typeof pos === "undefined" ? 2 : parseInt(pos));
5859
num = String(arg).indexOf(".") > -1 ? parseFloat(arg) : parseInt(arg);
59-
sizes = ["B:0", "KB:1024", "MB:1048576", "GB:1073741824", "TB:1099511627776"];
60+
sizes = [["B", 0], ["KB", 1024], ["MB", 1048576], ["GB", 1073741824], ["TB", 1099511627776]];
6061
i = sizes.length;
6162
result = "";
6263
regex = /\.(.*)/;
6364

6465
while (i--) {
65-
x = sizes[i].split(":");
66-
size = parseInt(x[1]);
67-
suffix = x[0];
66+
size = sizes[i][1];
67+
suffix = sizes[i][0];
6868
if (num >= size) {
6969
result = (suffix === "B" ? num : (num / size)).toFixed(pos);
7070
if (short) {
@@ -85,7 +85,7 @@
8585
module.exports = filesize;
8686
break;
8787
case typeof define === "function":
88-
define("filesize", function () { return filesize; });
88+
define(function () { return filesize; });
8989
break;
9090
default:
9191
global.filesize = filesize;

production/filesize.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131
* Transforms a file size Number into a readable String
3232
*
3333
* @author Jason Mulligan <[email protected]>
34+
* @link http://filesizejs.com
3435
* @module filesize
35-
* @version 1.6.4
36+
* @version 1.6.5
3637
*
3738
* @param {Mixed} arg String, Int or Float to transform
3839
* @param {Number} pos [Optional] Position to round to, defaults to 2 if short is ommitted
3940
* @param {Boolean} short [Optional] Shorthand output, similar to "ls -lh", overrides pos to 1
40-
* @return {String} Readable file size String
41+
* @return {String} Readable file size String
4142
*/
42-
(function(a){"use strict";var b=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;typeof arguments[2]!="undefined"?(b=arguments[1],c=arguments[2]):typeof arguments[1]=="boolean"?c=arguments[1]:b=arguments[1];if(isNaN(a)||typeof b!="undefined"&&isNaN(b))throw Error("Invalid arguments");c=c===!0,b=c?1:typeof b=="undefined"?2:parseInt(b),d=String(a).indexOf(".")>-1?parseFloat(a):parseInt(a),e=["B:0","KB:1024","MB:1048576","GB:1073741824","TB:1099511627776"],j=e.length,g="",h=/\.(.*)/;while(j--){l=e[j].split(":"),f=parseInt(l[1]),i=l[0];if(d>=f){g=(i==="B"?d:d/f).toFixed(b),c&&(i=i.slice(0,1),m=h.exec(g),m!==null&&typeof m[1]!="undefined"&&m[1]==="0"&&(g=parseInt(g))),g+=i;break}}return g};switch(!0){case typeof exports!="undefined":module.exports=b;break;case typeof define=="function":define("filesize",function(){return b});break;default:a.filesize=b}})(this)
43+
(function(a){"use strict";var b=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;typeof arguments[2]!="undefined"?(b=arguments[1],c=arguments[2]):typeof arguments[1]=="boolean"?c=arguments[1]:b=arguments[1];if(isNaN(a)||typeof b!="undefined"&&isNaN(b))throw Error("Invalid arguments");c=c===!0,b=c?1:typeof b=="undefined"?2:parseInt(b),d=String(a).indexOf(".")>-1?parseFloat(a):parseInt(a),e=[["B",0],["KB",1024],["MB",1048576],["GB",1073741824],["TB",1099511627776]],j=e.length,g="",h=/\.(.*)/;while(j--){f=e[j][1],i=e[j][0];if(d>=f){g=(i==="B"?d:d/f).toFixed(b),c&&(i=i.slice(0,1),m=h.exec(g),m!==null&&typeof m[1]!="undefined"&&m[1]==="0"&&(g=parseInt(g))),g+=i;break}}return g};switch(!0){case typeof exports!="undefined":module.exports=b;break;case typeof define=="function":define(function(){return b});break;default:a.filesize=b}})(this)

0 commit comments

Comments
 (0)