Skip to content

Commit 829b250

Browse files
committed
Added 'byte' as the smallest size, fixes S3 file size computing, etc.
1 parent 11f5015 commit 829b250

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

debug/filesize.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* filesize.js
3030
*
3131
* @author Jason Mulligan <[email protected]>
32-
* @version 1.0
32+
* @version 1.1
3333
*/
3434
(function (window) {
3535
"use strict";
@@ -43,7 +43,7 @@
4343
*/
4444
var filesize = function (arg, pos) {
4545
var num = String(arg).indexOf(".") > -1 ? parseFloat(arg) : parseInt(arg),
46-
sizes = [{"kB": 0}, {"MB": 1024}, {"GB": 1048576}, {"TB": 1073741824}],
46+
sizes = [{"B": 0}, {"KB": 1024}, {"MB": 1048576}, {"GB": 1073741824}, {"TB": 1099511627776}],
4747
i = sizes.length,
4848
result = "",
4949
size, suffix, n, x;
@@ -59,7 +59,7 @@
5959
}
6060
}
6161
if (num >= size) {
62-
result = (suffix === "kB" ? num : (num / size).toFixed(pos)) + suffix;
62+
result = (suffix === "B" ? num : (num / size).toFixed(pos)) + suffix;
6363
break;
6464
}
6565
}

production/filesize.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
* filesize.js
3030
*
3131
* @author Jason Mulligan <[email protected]>
32-
* @version 1.0
32+
* @version 1.1
3333
*/
34-
(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)
34+
(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 commit comments

Comments
 (0)