mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 15:28:47 +00:00
add speedtest-tracker integration
This commit is contained in:
parent
0076701091
commit
ac718c852a
4 changed files with 55 additions and 1 deletions
|
@ -21,3 +21,15 @@ export function formatBytes(bytes, decimals = 2) {
|
|||
|
||||
return parseFloat(bytes / Math.pow(k, i)).toFixed(dm) + " " + sizes[i];
|
||||
}
|
||||
|
||||
export function formatBits(bytes, decimals = 2) {
|
||||
if (bytes === 0) return "0 Bytes";
|
||||
|
||||
const k = 1024;
|
||||
const dm = decimals < 0 ? 0 : decimals;
|
||||
const sizes = ["B", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"];
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
|
||||
return parseFloat(bytes / Math.pow(k, i)).toFixed(dm) + " " + sizes[i];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue