function formatBytes(bytes, decimals = 2) { if (bytes === 0) { return "0 Bytes"; } const k = 1024; const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; const i = Math.floor(Math.log(bytes) / Math.log(k)); return `${Number.parseFloat((bytes / k ** i).toFixed(decimals))} ${sizes[i]}`; } export { formatBytes as f };