Skip to content

Commit

Permalink
Merge pull request #15 from Tarrowren/main
Browse files Browse the repository at this point in the history
Add cancellation support
  • Loading branch information
aeschli authored Nov 3, 2022
2 parents 6dbdc1e + 44e5b82 commit a4ae2b3
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 3,455 deletions.
38 changes: 37 additions & 1 deletion api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface XHROptions {
data?: string;
strictSSL?: boolean;
followRedirects?: number;
token?: CancellationToken;
agent?: HttpProxyAgent | HttpsProxyAgent;
}

Expand All @@ -30,6 +31,41 @@ export interface XHRConfigure {
(proxyUrl: string | undefined, strictSSL: boolean): void;
}

export interface Disposable {
/**
* Dispose this object.
*/
dispose(): void;
}
/**
* Represents a typed event.
*/
export interface Event<T> {
/**
*
* @param listener The listener function will be call when the event happens.
* @param thisArgs The 'this' which will be used when calling the event listener.
* @param disposables An array to which a {{IDisposable}} will be added. The
* @return
*/
(listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]): Disposable;
}
/**
* Defines a CancellationToken. This interface is not
* intended to be implemented. A CancellationToken must
* be created via a CancellationTokenSource.
*/
export interface CancellationToken {
/**
* Is `true` when the token has been cancelled, `false` otherwise.
*/
readonly isCancellationRequested: boolean;
/**
* An [event](#Event) which fires upon cancellation.
*/
readonly onCancellationRequested: Event<any>;
}

export type HttpProxyAgent = import('http-proxy-agent').HttpProxyAgent;

export type HttpsProxyAgent = import('https-proxy-agent').HttpsProxyAgent;
Expand All @@ -39,4 +75,4 @@ export type Headers = { [header: string]: string | string[] | undefined };
export declare const configure: XHRConfigure;
export declare const xhr: XHRRequest;

export declare function getErrorStatusDescription(status: number): string;
export declare function getErrorStatusDescription(status: number): string;
Loading

0 comments on commit a4ae2b3

Please sign in to comment.