Skip to content

Instantly share code, notes, and snippets.

View miaozilong's full-sized avatar

miaozilong miaozilong

View GitHub Profile
@gucheen
gucheen / readablizeBytes.js
Created March 4, 2014 09:02
文件大小单位转换
function readablizeBytes(bytes) {
var s = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
var e = Math.floor(Math.log(bytes)/Math.log(1024));
return (bytes/Math.pow(1024, Math.floor(e))).toFixed(2)+" "+s[e];
}