-
-
Save rockydd/2ca18f239e289167719c 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
Object.defineProperty(Number.prototype,'fileSize',{value:function(a,b,c,d){ | |
if(this == 0){ | |
return "0.0 B"; | |
}else if(this < 0.001){ | |
return this.toExponential(1) + " B"; | |
}else if(this < 1){ | |
return this.toLocaleString() + " B"; | |
} | |
return (a=a?[1e3,'k','B']:[1024,'K','iB'],b=Math,c=b.log, | |
d=c(this)/c(a[0])|0,this/b.pow(a[0],d)).toFixed(1) | |
+' '+(d?(a[1]+'MGTPEZY')[--d]+a[2]:'B'); | |
},writable:false,enumerable:false}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment