mirror of
https://github.com/ivabus/gui
synced 2025-04-23 14:07:14 +03:00
Less decimals
This commit is contained in:
parent
4d19688c87
commit
7bc8a958bb
1 changed files with 5 additions and 2 deletions
|
@ -20,11 +20,14 @@
|
|||
unit = "MB";
|
||||
divisor = 1024 ** 2;
|
||||
} else if (n > 1024) {
|
||||
unit = "KB";
|
||||
unit = "kB";
|
||||
divisor = 1024;
|
||||
}
|
||||
|
||||
return `${(n / divisor).toFixed(2)} ${unit}`;
|
||||
const N = n / divisor;
|
||||
const decimals = n < 10 ? 2 : 1; // it’s more informative to show more decimals but only for smaller numbers
|
||||
|
||||
return `${N.toFixed(decimals)} ${unit}`;
|
||||
};
|
||||
console.log(pkg);
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue