标签:port return let cti floor size == math pow
export function bytesToSize(bytes){
if (bytes === 0) return ‘0 B‘
let k = 1024, // or 1000
sizes = [‘B‘, ‘KB‘, ‘MB‘, ‘GB‘, ‘TB‘, ‘PB‘, ‘EB‘, ‘ZB‘, ‘YB‘],
i = Math.floor(Math.log(bytes) / Math.log(k))
return (bytes / Math.pow(k, i)).toPrecision(3) + ‘ ‘ + sizes[i]
}
标签:port return let cti floor size == math pow
原文地址:https://www.cnblogs.com/zhoudawei/p/9551800.html