forked from CarterLi/websocketstream-polyfill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
26 lines (26 loc) · 945 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
export interface WebSocketConnection<T extends Uint8Array | string = Uint8Array | string> {
readable: ReadableStream<T>;
writable: WritableStream<T>;
protocol: string;
extensions: string;
}
export interface WebSocketCloseInfo {
closeCode?: number;
reason?: string;
}
export interface WebSocketStreamOptions {
protocols?: string[];
signal?: AbortSignal;
}
/**
* [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) with [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)
*
* @see https://web.dev/websocketstream/
*/
export declare class WebSocketStream<T extends Uint8Array | string = Uint8Array | string> {
readonly url: string;
readonly opened: Promise<WebSocketConnection<T>>;
readonly closed: Promise<WebSocketCloseInfo>;
readonly close: (closeInfo?: WebSocketCloseInfo) => void;
constructor(url: string, options?: WebSocketStreamOptions);
}