This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
|
const SIZES = [
|
|
'B',
|
|
'KB',
|
|
'MB',
|
|
'GB',
|
|
'TB',
|
|
] as const
|
|
|
|
export function getHumanSize(inputSize: number) {
|
|
let iterator = 0
|
|
let size = inputSize
|
|
while (size > 1024) {
|
|
size /= 1024
|
|
iterator++
|
|
}
|
|
|
|
return Number(Math.round(Number(size + 'e2')) + 'e-2') + ' ' + SIZES[iterator]
|
|
} |