Refactor: speed up reject parsing

This commit is contained in:
SukkaW
2023-12-17 23:37:35 +08:00
parent 91ed783d73
commit 16a08bd07d
13 changed files with 175 additions and 159 deletions

View File

@@ -16,10 +16,10 @@ const latestTopUserAgentsPromise = fetchWithRetry('https://unpkg.com/top-user-ag
.then(res => res.json() as Promise<string[]>);
const querySpeedtestApi = async (keyword: string): Promise<Array<string | null>> => {
const [topUserAgents] = await Promise.all([
const topUserAgents = (await Promise.all([
latestTopUserAgentsPromise,
s.acquire()
]);
]))[0];
const randomUserAgent = topUserAgents[Math.floor(Math.random() * topUserAgents.length)];