Created
September 30, 2019 13:34
-
-
Save deep5050/fb09be5e39a970ca862f2206e3ffa283 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
var bytesToSize = function (a, b) { | |
if (0 === a) return "0 Bytes"; | |
var c = 1024, d = b || 2, e = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], | |
f = Math.floor(Math.log(a) / Math.log(c)); | |
return parseFloat((a / Math.pow(c, f)).toFixed(d)) + " " + e[f] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment