Created
June 3, 2018 17:39
-
-
Save luislobo14rap/4c873c32ee4b6cb0789913c79e6f5245 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// formatBytes.min.js v1, https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript | |
function formatBytes(t,B){if(0==t)return'0 Bytes';var o=B||2,a=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,a)).toFixed(o))+' '+['Bytes','KB','MB','GB','TB','PB','EB','ZB','YB'][a]}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
deprecated in favor of https://gist.github.com/luislobo14rap/b0368c1ed36a809bac667d8301152baa