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
Show file tree
Hide file tree
Changes from all commits
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
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.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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.

95 changes: 79 additions & 16 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,47 @@ export type MeasurementConfig = {
connectionTimeout?: number,
};

export interface RawResults {
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
},
}

export interface ConfigOptions {
autoStart?: boolean;

Expand Down Expand Up @@ -42,7 +83,7 @@ export interface ConfigOptions {
loadedLatencyMaxPoints?: number
}

interface BandwidthPoint {
export interface BandwidthPoint {
bytes: number,
bps: number,
duration: number,
Expand All @@ -52,22 +93,43 @@ interface BandwidthPoint {
transferSize: number
}

export interface ResultTiming extends BandwidthPoint {
payloadDownloadTime: 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 interface GetSummary {
download?: number,
upload?: number,
latency?: number,
jitter?: number,
downLoadedLatency?: number,
downLoadedJitter?: number,
upLoadedLatency?: number,
upLoadedJitter?: number,
packetLoss?: number,
}

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

readonly isFinished: boolean;

getSummary: () => {
download?: number,
upload?: number,
latency?: number,
jitter?: number,
downLoadedLatency?: number,
downLoadedJitter?: number,
upLoadedLatency?: number,
upLoadedJitter?: number,
packetLoss?: number,
}
getSummary: () => GetSummary;

getUnloadedLatency: () => number | undefined;
getUnloadedJitter: () => number | undefined;
Expand Down Expand Up @@ -96,11 +158,12 @@ export declare class Results {
classificationIdx: 0 | 1 | 2 | 3 | 4;
classificationName: 'bad' | 'poor' | 'average' | 'good' | 'great';
}
}
};
raw: RawResults;
}

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

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

export default SpeedTestEngine;
export default SpeedTestEngine;