atmosphere explorer pds.ls
tool typescript atproto

use binary notation for filesizes

handle.invalid 3a608500 e3b35589

verified
+1 -1
+1 -1
src/utils/format.ts
··· 1 1 const formatFileSize = (bytes: number): string => { 2 2 if (bytes === 0) return "0 B"; 3 3 const k = 1024; 4 - const sizes = ["B", "KB", "MB", "GB"]; 4 + const sizes = ["B", "KiB", "MiB", "GiB"]; 5 5 const i = Math.floor(Math.log(bytes) / Math.log(k)); 6 6 return `${(bytes / Math.pow(k, i)).toFixed(i === 0 ? 0 : 1)} ${sizes[i]}`; 7 7 };