You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
344 B
12 lines
344 B
3 years ago
|
module.exports = function getsize(bytes) {
|
||
|
let val = bytes;
|
||
|
let types = ['Bytes', 'Kilobytes', 'Megabytes', 'Gigabytes', 'Terabytes'];
|
||
|
reit = 0;
|
||
|
while (true) {
|
||
|
if (val > 1000) {
|
||
|
val = (val / 1024).toFixed(2);
|
||
|
reit++;
|
||
|
} else {break;}
|
||
|
}
|
||
|
return `${val} ${types[reit]}`;
|
||
|
};
|