Skip to content

Commit

Permalink
Added 'byte' as the smallest size, fixes S3 file size computing, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Mar 2, 2012
1 parent 11f5015 commit 829b250
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions debug/filesize.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* filesize.js
*
* @author Jason Mulligan <jason.mulligan@avoidwork.com>
* @version 1.0
* @version 1.1
*/
(function (window) {
"use strict";
Expand All @@ -43,7 +43,7 @@
*/
var filesize = function (arg, pos) {
var num = String(arg).indexOf(".") > -1 ? parseFloat(arg) : parseInt(arg),
sizes = [{"kB": 0}, {"MB": 1024}, {"GB": 1048576}, {"TB": 1073741824}],
sizes = [{"B": 0}, {"KB": 1024}, {"MB": 1048576}, {"GB": 1073741824}, {"TB": 1099511627776}],
i = sizes.length,
result = "",
size, suffix, n, x;
Expand All @@ -59,7 +59,7 @@
}
}
if (num >= size) {
result = (suffix === "kB" ? num : (num / size).toFixed(pos)) + suffix;
result = (suffix === "B" ? num : (num / size).toFixed(pos)) + suffix;
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions production/filesize.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
* filesize.js
*
* @author Jason Mulligan <jason.mulligan@avoidwork.com>
* @version 1.0
* @version 1.1
*/
(function(a){"use strict";var b=function(a,b){var c=String(a).indexOf(".")>-1?parseFloat(a):parseInt(a),d=[{kB:0},{MB:1024},{GB:1048576},{TB:1073741824}],e=d.length,f="",g,h,i,j;b=typeof b=="undefined"?2:parseInt(b);while(e--){j=d[e];for(i in j)j.hasOwnProperty(i)&&(g=j[i],h=i);if(c>=g){f=(h==="kB"?c:(c/g).toFixed(b))+h;break}}return f};typeof define=="function"?define("filesize",[],function(){return b}):a.filesize=b})(window)
(function(a){"use strict";var b=function(a,b){var c=String(a).indexOf(".")>-1?parseFloat(a):parseInt(a),d=[{B:0},{KB:1024},{MB:1048576},{GB:1073741824},{TB:1099511627776}],e=d.length,f="",g,h,i,j;b=typeof b=="undefined"?2:parseInt(b);while(e--){j=d[e];for(i in j)j.hasOwnProperty(i)&&(g=j[i],h=i);if(c>=g){f=(h==="B"?c:(c/g).toFixed(b))+h;break}}return f};typeof define=="function"?define("filesize",[],function(){return b}):a.filesize=b})(window)

0 comments on commit 829b250

Please sign in to comment.