revite/src/lib/fileSize.ts
2021-07-05 11:23:23 +01:00

9 lines
206 B
TypeScript

export function determineFileSize(size: number) {
if (size > 1e6) {
return `${(size / 1e6).toFixed(2)} MB`;
} else if (size > 1e3) {
return `${(size / 1e3).toFixed(2)} KB`;
}
return `${size} B`;
}