fix(core): update
This commit is contained in:
@@ -64,7 +64,7 @@ export class CloudflareSpeed {
|
||||
}
|
||||
|
||||
public async measureDownload(bytes: number, iterations: number) {
|
||||
const measurements = [];
|
||||
const measurements: number[] = [];
|
||||
|
||||
for (let i = 0; i < iterations; i += 1) {
|
||||
await this.download(bytes).then(
|
||||
@@ -82,7 +82,7 @@ export class CloudflareSpeed {
|
||||
}
|
||||
|
||||
public async measureUpload(bytes: number, iterations: number) {
|
||||
const measurements = [];
|
||||
const measurements: number[] = [];
|
||||
|
||||
for (let i = 0; i < iterations; i += 1) {
|
||||
await this.upload(bytes).then(
|
||||
@@ -106,11 +106,11 @@ export class CloudflareSpeed {
|
||||
public async fetchServerLocations(): Promise<{ [key: string]: string }> {
|
||||
const res = JSON.parse(await this.get('speed.cloudflare.com', '/locations'));
|
||||
|
||||
return res.reduce((data, { iata, city }) => {
|
||||
return res.reduce((data: any, optionsArg: { iata: string, city: string}) => {
|
||||
// Bypass prettier "no-assign-param" rules
|
||||
const data1 = data;
|
||||
|
||||
data1[iata] = city;
|
||||
data1[optionsArg.iata] = optionsArg.city;
|
||||
return data1;
|
||||
}, {});
|
||||
}
|
||||
@@ -124,7 +124,7 @@ export class CloudflareSpeed {
|
||||
method: 'GET',
|
||||
},
|
||||
(res) => {
|
||||
const body = [];
|
||||
const body: Array<Buffer> = [];
|
||||
res.on('data', (chunk) => {
|
||||
body.push(chunk);
|
||||
});
|
||||
@@ -145,7 +145,7 @@ export class CloudflareSpeed {
|
||||
});
|
||||
}
|
||||
|
||||
public async download(bytes) {
|
||||
public async download(bytes: number) {
|
||||
const options = {
|
||||
hostname: 'speed.cloudflare.com',
|
||||
path: `/__down?bytes=${bytes}`,
|
||||
@@ -169,13 +169,13 @@ export class CloudflareSpeed {
|
||||
return this.request(options, data);
|
||||
}
|
||||
|
||||
public async request(options, data = '') {
|
||||
let started;
|
||||
let dnsLookup;
|
||||
let tcpHandshake;
|
||||
let sslHandshake;
|
||||
let ttfb;
|
||||
let ended;
|
||||
public async request(options: plugins.https.RequestOptions, data = ''): Promise<number[]> {
|
||||
let started: number;
|
||||
let dnsLookup: number;
|
||||
let tcpHandshake : number;
|
||||
let sslHandshake: number;
|
||||
let ttfb: number;
|
||||
let ended: number;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
started = plugins.perfHooks.performance.now();
|
||||
@@ -234,7 +234,7 @@ export class CloudflareSpeed {
|
||||
warp: string;
|
||||
gateway: string;
|
||||
}> {
|
||||
const parseCfCdnCgiTrace = (text) =>
|
||||
const parseCfCdnCgiTrace = (text: string) =>
|
||||
text
|
||||
.split('\n')
|
||||
.map((i) => {
|
||||
@@ -242,7 +242,7 @@ export class CloudflareSpeed {
|
||||
|
||||
return [j[0], j[1]];
|
||||
})
|
||||
.reduce((data, [k, v]) => {
|
||||
.reduce((data: any, [k, v]) => {
|
||||
if (v === undefined) return data;
|
||||
|
||||
// Bypass prettier "no-assign-param" rules
|
||||
|
Reference in New Issue
Block a user