1export default (bytes) => {
2 const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
3 if (bytes === 0) return "n/a";
4 const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10);
5 if (i === 0) return `${bytes} ${sizes[i]})`;
6 return `${(bytes / (1024 ** i)).toFixed(1)} ${sizes[i]}`;
7};