Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types for the results.raw object added to the index.d.ts #31

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
type for the raw object in the results
John Carmichael committed Oct 29, 2023
commit f720d8072a3db00155abab2e9f723a1112cfc372
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/cloudflare-speedtest.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/markdown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 71 additions & 6 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ export interface ConfigOptions {
loadedLatencyMaxPoints?: number
}

interface BandwidthPoint {
export interface BandwidthPoint {
bytes: number,
bps: number,
duration: number,
@@ -52,8 +52,33 @@ interface BandwidthPoint {
transferSize: number
}

export interface ResultTiming {
bps: number,
duration: number,
measTime: Date,
payloadDownloadTime: number,
ping: number,
serverTime: number,
transferSize: number,
ttfb: number,
}

export interface ResultDownloadTiming extends ResultTiming {
type: string;
}

export interface ResultLatency extends ResultTiming {
bytes: number;
}

export interface ResultDownload {
numMeasurements: number,
sideLatency: ResultLatency[],
timings: ResultDownloadTiming[]
}

export declare class Results {
constructor();
constructor ();

readonly isFinished: boolean;

@@ -67,7 +92,7 @@ export declare class Results {
upLoadedLatency?: number,
upLoadedJitter?: number,
packetLoss?: number,
}
};

getUnloadedLatency: () => number | undefined;
getUnloadedJitter: () => number | undefined;
@@ -96,11 +121,51 @@ export declare class Results {
classificationIdx: 0 | 1 | 2 | 3 | 4;
classificationName: 'bad' | 'poor' | 'average' | 'good' | 'great';
}
}
};
raw: {
download: {
finished: boolean,
results: {
'100000'?: ResultDownload,
'1000000'?: ResultDownload,
'10000000'?: ResultDownload,
},
stated: boolean
},
latency: {
finished: boolean,
results: {
numMeasurements: number,
timings: ResultTiming[],
start: boolean,
},
stated: boolean
},
packetLoss: {
finished: boolean,
results: {
lostMessages: any[],
numMessagesSent: number,
packetLoss: number,
totalMessages: number,
},
stated: boolean
},
upload: {
finished: boolean,
finishedCurrentRound: boolean,
results: {
'100000'?: ResultDownload,
'1000000'?: ResultDownload,
'10000000'?: ResultDownload,
},
stated: boolean
},
};
}

declare class SpeedTestEngine {
constructor(config?: ConfigOptions);
constructor (config?: ConfigOptions);

play: () => void;
pause: () => void;
@@ -116,4 +181,4 @@ declare class SpeedTestEngine {
onError: (error: string) => void;
}

export default SpeedTestEngine;
export default SpeedTestEngine;