-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransport.d.ts
More file actions
55 lines (41 loc) · 1.3 KB
/
Transport.d.ts
File metadata and controls
55 lines (41 loc) · 1.3 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* eslint max-len: 0 */
// import type { EventEmitter } from 'node:events'
// import type { TypedEmitter } from 'tiny-typed-emitter'
// type Data = string | Buffer | ArrayBuffer | Buffer[];
// export type TypedArray = (Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array)
// export type PayloadBinary = (ArrayBuffer | Blob | TypedArray | DataView)
// import type { BufferLike } from 'ws'
// import type { ErrorEvent } from '@types/ws'
// import type * as WebSocket from 'ws'
import type { TypedEventTarget } from 'typescript-event-target'
import type { Status } from './status.js'
export type Binary_Send = (Buffer | ArrayBuffer | DataView | ArrayBufferView | Uint8Array | SharedArrayBuffer)
export type Binary_Recv = (Buffer | ArrayBuffer | Buffer[])
export type Payload = (string | Binary_Recv)
export type Events =
{
open: Event,
close: Event, /* TODO: CloseEvent */
error: Event,
message: MessageEvent,
}
export interface Transport extends TypedEventTarget<Events>
{
capabilities?:
{
binary?: boolean,
reconnect?: boolean,
},
readyState: Status,
send (payload: string): void,
close (): void,
}
export type TransportBinary = Transport
&
{
capabilities:
{
binary: true,
},
send (payload: Binary_Send): void,
}