14 lines
268 B
JavaScript
14 lines
268 B
JavaScript
function getNextUnit(bSize) {
|
|
units = ["B", "kB", "MB", "GB", "TB", "PB", "To damn high"]
|
|
iters = 0
|
|
size = bSize
|
|
do {
|
|
size /= 1024
|
|
iters++
|
|
} while(size >= 1)
|
|
size *= 1024
|
|
if(iters > units.length) { iters = units.length }
|
|
return [size, units[iters - 1]]
|
|
}
|
|
|