chore: clean up usage of Object.keys (#14484)

This commit is contained in:
Kayla Washburn-Love
2024-08-29 17:21:29 -06:00
committed by GitHub
parent d2a22c538b
commit 4672849d05
10 changed files with 83 additions and 111 deletions
+3 -15
View File
@@ -233,21 +233,9 @@ const selectByLatency = (
return undefined;
}
const proxyMap = proxies.reduce(
(acc, proxy) => {
acc[proxy.id] = proxy;
return acc;
},
{} as Record<string, Region>,
);
const best = Object.keys(latencies)
.map((proxyId) => {
return {
id: proxyId,
...latencies[proxyId],
};
})
const proxyMap = Object.fromEntries(proxies.map((it) => [it.id, it]));
const best = Object.entries(latencies)
.map(([proxyId, latency]) => ({ id: proxyId, ...latency }))
// If the proxy is not in our list, or it is unhealthy, ignore it.
.filter((latency) => proxyMap[latency.id]?.healthy)
.sort((a, b) => a.latencyMS - b.latencyMS)