Created
June 9, 2016 20:37
-
-
Save sirdlx/0c3b61c186279bbb3f90559e533fd9bc to your computer and use it in GitHub Desktop.
format bytes to text: 243.6 BG
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
let bytesText = function formatBytesText(bytes) { | |
if(bytes < 1024) return bytes + " Bytes"; | |
else if(bytes < 1048576) return(bytes / 1024).toFixed(2) + " KB"; | |
else if(bytes < 1073741824) return(bytes / 1048576).toFixed(2) + " MB"; | |
else return(bytes / 1073741824).toFixed(2) + " GB"; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment