Fix #1 files less than 1KB showing as negative
This commit is contained in:
parent
b2b71b5d10
commit
d0c8c91250
@ -39,13 +39,13 @@ const sizes = {
|
|||||||
'GB': Math.pow(2, 30),
|
'GB': Math.pow(2, 30),
|
||||||
'MB': Math.pow(2, 20),
|
'MB': Math.pow(2, 20),
|
||||||
'KB': Math.pow(2, 10),
|
'KB': Math.pow(2, 10),
|
||||||
'B': -1
|
'B': 0
|
||||||
}
|
}
|
||||||
export function humanSize(size) {
|
export function humanSize(size) {
|
||||||
for (let key in sizes) {
|
for (let key in sizes) {
|
||||||
let value = sizes[key];
|
let value = sizes[key];
|
||||||
|
|
||||||
if (size > value) {
|
if (size >= value) {
|
||||||
return Math.round(size / value) + key;
|
return Math.round(size / value) + key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user