summaryrefslogtreecommitdiff
path: root/types/web-socket-stream/index.d.ts
blob: ebecb2260a5ecc298abd670ce3e4f543ce5fc309 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
declare interface WebSocketOpenInfo {
    readable: ReadableStream
    writable: WritableStream
    extensions: string
    protocol: string
}

declare interface WebSocketCloseInfo {
    closeCode: number
    reason: string
}

declare interface WebSocketStreamOptions {
    protocols?: string[]
    signal?: AbortSignal
}

declare class WebSocketStream {
    constructor(url: string, options?: WebSocketStreamOptions)
    readonly url: string
    readonly opened: Promise<WebSocketOpenInfo>
    readonly closed: Promise<WebSocketCloseInfo>
    close(closeInfo?: WebSocketCloseInfo): any
}