// Sizes and rates, shown the way the rest of the console shows them. These lived in // Dashboard.tsx until that page was retired (2026-09-23); Disks, Files and Space all use // them, so they belong on their own. // fmtBytes is binary — what a disk or a file actually occupies. export function fmtBytes(b: number): string { const u = ['B', 'KiB', 'MiB', 'GiB', 'TiB'] let i = 0 while (b >= 1024 && i < u.length - 1) { b /= 1024; i++ } return `${b < 10 && i > 0 ? b.toFixed(1) : Math.round(b)} ${u[i]}` } // fmtRate is decimal — how throughput is quoted everywhere else. export function fmtRate(bps: number): string { const u = ['B/s', 'kB/s', 'MB/s', 'GB/s'] let i = 0 while (bps >= 1000 && i < u.length - 1) { bps /= 1000; i++ } return `${bps < 10 && i > 0 ? bps.toFixed(1) : Math.round(bps)} ${u[i]}` }