You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
9 lines
302 B
9 lines
302 B
exports = function(bytes) {
|
|
if (bytes <= 0) return '0';
|
|
var suffixIdx = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
var val = bytes / Math.pow(2, suffixIdx * 10);
|
|
return +val.toFixed(2) + suffixList[suffixIdx];
|
|
};
|
|
var suffixList = ['', 'K', 'M', 'G', 'T'];
|
|
|
|
module.exports = exports;
|
|
|