15 lines
252 B
TypeScript
Raw Normal View History

2018-04-17 11:01:51 +00:00
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}`
}