Skip to content

Instantly share code, notes, and snippets.

@fat
Created December 9, 2010 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fat/735437 to your computer and use it in GitHub Desktop.
Save fat/735437 to your computer and use it in GitHub Desktop.
Dashboard.Format = {
types: {
bytes: ['b', 'kb', 'MB', 'GB', 'TB', 'PB'],
integer: ['', 'K', 'M', 'B', 'T', 'P']
},
abbreviate: function(metric, value){
var i = value ? Math.floor(Math.log(value)/Math.log(metric.devisor)) : 0;
return (value/Math.pow(metric.devisor, Math.floor(i))).round(2).format({
group: ',',
suffix: this.types[metric.type][i]
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment