File
Blob: src/client/islands/repo-admin/format.ts
| 1 | export function formatSampleBytes(bytes?: number): string { |
| 2 | if (bytes === undefined || bytes === null) return "0 KB"; |
| 3 | const mb = bytes / 1048576; |
| 4 | if (mb >= 1) return `${mb.toFixed(2)} MB`; |
| 5 | return `${(bytes / 1024).toFixed(1)} KB`; |
| 6 | } |
| 7 | |
| 8 | export function shortValue(value: string, length: number): string { |
| 9 | return value.length > length ? `${value.slice(0, length)}...` : value; |
| 10 | } |