Skip to content

Commit

Permalink
add Util.humanReadableNumber method
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuels committed Oct 26, 2012
1 parent a081bd4 commit 96e1df0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/JBrowse/Util.js
Expand Up @@ -161,6 +161,26 @@ Util = {
return a;
},

humanReadableNumber: function( num ) {
num = parseInt(num);
var suffix = '';
if( num >= 1e12 ) {
num /= 1e12;
suffix = 'T';
} else if( num >= 1e9 ) {
num /= 1e9;
suffix = 'G';
} else if( num >= 1e6 ) {
num /= 1e6;
suffix = 'M';
} else if( num >= 1000 ) {
num /= 1000;
suffix = 'K';
}

return (num.toFixed(2)+' '+suffix).replace(/0+ /,' ').replace(/\. /,' ');
},

// from http://bugs.dojotoolkit.org/ticket/5794
resolveUrl: function(baseUrl, relativeUrl) {
// summary:
Expand Down

0 comments on commit 96e1df0

Please sign in to comment.