16 lines
261 B
TypeScript
Raw Normal View History

2019-11-18 02:04:13 +00:00
export default function bytesHumanReadable(fileSize: number): string {
2018-04-17 11:01:51 +00:00
let unit = "bytes"
if(fileSize >= 1024) {
fileSize /= 1024
unit = "KB"
if(fileSize >= 1024) {
fileSize /= 1024
unit = "MB"
}
}
return `${fileSize.toFixed(0)} ${unit}`
2019-11-17 09:44:30 +00:00
}