Created
May 14, 2018 13:18
-
-
Save null4bl3/80e34b6da56d2c69180984de07c4bfe9 to your computer and use it in GitHub Desktop.
return a ceil + parseint value
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
formatBytes(bytes) { | |
if (bytes < 1024) { | |
return bytes + " Bytes"; | |
} else if (bytes < 1048576) { | |
return parseInt(Math.ceil(bytes / 1024).toFixed(3), 10) + " KB"; | |
} else if (bytes < 1073741824) { | |
return parseInt(Math.ceil(bytes / 1048576).toFixed(3), 10) + " MB"; | |
} else { | |
return parseInt(Math.ceil(bytes / 1073741824).toFixed(3), 10) + " GB"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment