docling-studio/frontend/src/shared/format.ts
2026-03-21 15:58:43 +01:00

5 lines
209 B
TypeScript

export function formatSize(bytes: number | null | undefined): string {
if (!bytes) return ''
const mb = bytes / (1024 * 1024)
return mb >= 1 ? `${mb.toFixed(1)} MB` : `${(bytes / 1024).toFixed(0)} KB`
}