2018-04-17 13:01:51 +02:00

15 lines
252 B
TypeScript

export function bytesHumanReadable(fileSize: number): string {
let unit = "bytes"
if(fileSize >= 1024) {
fileSize /= 1024
unit = "KB"
if(fileSize >= 1024) {
fileSize /= 1024
unit = "MB"
}
}
return `${fileSize.toFixed(0)} ${unit}`
}