Skip to content

Instantly share code, notes, and snippets.

@ivoputzer
Created May 11, 2014 18:29
Show Gist options
  • Save ivoputzer/ed901d38ef184e51bd08 to your computer and use it in GitHub Desktop.
Save ivoputzer/ed901d38ef184e51bd08 to your computer and use it in GitHub Desktop.
angular.js filter for byte format
.filter('bytes', [function(){
return function bytes(a, b, c, d, e){
return (b=Math,c=b.log,d=1e3,e=c(a)/c(d)|0,a/b.pow(d,e)).toFixed(2) + (e?'kMGTPEZY'[--e]+'B':'Bytes')
}
}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment