Skip to content

Commit

Permalink
Merge pull request #21 from omersaeed/master
Browse files Browse the repository at this point in the history
Minor change in gloss to get Tera Bytes and Peta Bytes in formats
  • Loading branch information
aaronj1335 committed Jul 20, 2012
2 parents bdb4ada + 039eb80 commit 80e1761
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/util/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ define([
10: options.units === 'short'? ' B' : ' Bytes',
20: options.units === 'short'? ' KB' : ' Kilobytes',
30: options.units === 'short'? ' MB' : ' Megabytes',
40: options.units === 'short'? ' GB' : ' Gigabytes'
40: options.units === 'short'? ' GB' : ' Gigabytes',
50: options.units === 'short'? ' TB' : ' Terabytes',
60: options.units === 'short'? ' PB' : ' Petabytes'
};

for (i in units)
if (bytes < Math.pow(2, i))
return (bytes / Math.pow(2, i-10)).toFixed(1) + units[i];
return (bytes / Math.pow(2, 30)).toFixed(1) + units[40];
return (bytes / Math.pow(2, 30)).toFixed(1) + units[60];
};

var inverse_bytes = function(s) {
Expand All @@ -30,6 +32,10 @@ define([
factor = 1000;
} else if (/gigabyte|gb/i.test(s)) {
factor = 1000000000;
} else if (/terabyte|tb/i.test(s)) {
factor = 1000000000000;
} else if (/petabyte|pb/i.test(s)) {
factor = 1000000000000000;
} else if (/b/i.test(s)) {
factor = 1;
} else {
Expand Down

0 comments on commit 80e1761

Please sign in to comment.