revite/src/lib/fileSize.ts

10 lines
230 B
TypeScript
Raw Normal View History

2021-06-19 17:37:12 -04:00
export function determineFileSize(size: number) {
2021-07-05 06:25:20 -04:00
if (size > 1e6) {
return `${(size / 1e6).toFixed(2)} MB`;
} else if (size > 1e3) {
return `${(size / 1e3).toFixed(2)} KB`;
}
2021-06-19 17:37:12 -04:00
2021-07-05 06:25:20 -04:00
return `${size} B`;
2021-06-19 17:37:12 -04:00
}