13 lines
360 B
TypeScript
13 lines
360 B
TypeScript
export function formatFileSize(sizeInKB: number): string {
|
|
if (sizeInKB < 1024) {
|
|
return `${sizeInKB.toFixed(2)} KB`;
|
|
} else {
|
|
const sizeInMB = sizeInKB / 1024;
|
|
return `${sizeInMB.toFixed(2)} MB`;
|
|
}
|
|
}
|
|
|
|
export function formatFileExtension(ext: string): string {
|
|
return ext.startsWith(".") ? ext.slice(1).toUpperCase() : ext.toUpperCase();
|
|
}
|