Node.js examples for Number:Format
Bytes To Size
function bytesToSize(bytes) { if (bytes === undefined || bytes === 0) { return '0' } var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'] var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10) var decimals = Math.max(0, i-1) return (bytes / Math.pow(1024, i)).toFixed(decimals) + ' ' + sizes[i] }