feat: supports show connection detail
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const UNITS = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||
|
||||
const parseTraffic = (num: number) => {
|
||||
const parseTraffic = (num?: number) => {
|
||||
if (typeof num !== "number") return ["NaN", ""];
|
||||
if (num < 1000) return [`${Math.round(num)}`, "B"];
|
||||
const exp = Math.min(Math.floor(Math.log2(num) / 10), UNITS.length - 1);
|
||||
const dat = num / Math.pow(1024, exp);
|
||||
|
||||
Reference in New Issue
Block a user