1export const formatSize = (bytes: number): string => { 2 const units = ['B', 'KB', 'MB', 'GB', 'TB'] 3 let i = 0 4 while (bytes >= 1024 && i < units.length - 1) { 5 bytes /= 1024 6 i++ 7 } 8 return `${bytes.toFixed(2)} ${units[i]}` 9}