fix(formatting): Fix minor formatting issues and newline consistency across project files

This commit is contained in:
2025-05-03 18:56:00 +00:00
parent 7d087e39ef
commit def467a27b
9 changed files with 53 additions and 50 deletions

View File

@@ -164,9 +164,10 @@ export class CloudflareSpeed {
}
public async fetchServerLocations(): Promise<{ [key: string]: string }> {
const res = JSON.parse(
await this.get('speed.cloudflare.com', '/locations'),
) as Array<{ iata: string; city: string }>;
const res = JSON.parse(await this.get('speed.cloudflare.com', '/locations')) as Array<{
iata: string;
city: string;
}>;
return res.reduce(
(data: Record<string, string>, optionsArg) => {
data[optionsArg.iata] = optionsArg.city;
@@ -198,9 +199,9 @@ export class CloudflareSpeed {
reject(e);
}
});
req.on('error', (err: Error & { code?: string }) => {
reject(new NetworkError(err.message, err.code));
});
req.on('error', (err: Error & { code?: string }) => {
reject(new NetworkError(err.message, err.code));
});
},
);
@@ -251,15 +252,15 @@ export class CloudflareSpeed {
res.on('data', () => {});
res.on('end', () => {
ended = plugins.perfHooks.performance.now();
resolve([
started,
dnsLookup,
tcpHandshake,
sslHandshake,
ttfb,
ended,
parseFloat((res.headers['server-timing'] as string).slice(22)),
]);
resolve([
started,
dnsLookup,
tcpHandshake,
sslHandshake,
ttfb,
ended,
parseFloat((res.headers['server-timing'] as string).slice(22)),
]);
});
});
@@ -296,11 +297,14 @@ export class CloudflareSpeed {
const parts = i.split('=');
return [parts[0], parts[1]];
})
.reduce((data: Record<string, string>, [k, v]) => {
if (v === undefined) return data;
data[k] = v;
return data;
}, {} as Record<string, string>);
.reduce(
(data: Record<string, string>, [k, v]) => {
if (v === undefined) return data;
data[k] = v;
return data;
},
{} as Record<string, string>,
);
return this.get('speed.cloudflare.com', '/cdn-cgi/trace').then(parseCfCdnCgiTrace);
}