Created
February 26, 2014 14:27
-
-
Save ewebdev/9230351 to your computer and use it in GitHub Desktop.
This file contains 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
function formatFileSize(bytes) { | |
var val = bytes / 1024, | |
suffix; | |
if (val < 1000) { | |
suffix = 'KB'; | |
} else { | |
val = val / 1024; | |
if (val < 1000) { | |
suffix = 'MB'; | |
} else { | |
val = val / 1024; | |
if (val < 1000) { | |
suffix = 'GB'; | |
} else { | |
val = val / 1024; | |
suffix = 'TB'; | |
} | |
} | |
} | |
return numericFormatters.round(val, 2) + suffix; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment