-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
87 lines (72 loc) · 1.97 KB
/
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
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import Buffer, { BufferEncoding } from 'bare-buffer'
import {
Readable,
ReadableOptions,
Writable,
WritableOptions,
PassThrough
} from 'bare-stream'
declare const constants: {
type: { REQUEST: 1; RESPONSE: 2; STREAM: 3 }
stream: {
OPEN: number
CLOSE: number
PAUSE: number
RESUME: number
DATA: number
END: number
DESTROY: number
ERROR: number
REQUEST: number
RESPONSE: number
}
}
interface RPCIncomingRequest {
readonly rpc: RPC
readonly id: number
readonly command: string
readonly data: Buffer
readonly sent: boolean
reply(data: Buffer | string, encoding?: BufferEncoding): void
createResponseStream(opts?: WritableOptions): RPCOutgoingStream
createRequestStream(opts?: ReadableOptions): RPCIncomingStream
}
declare class RPCIncomingRequest {
constructor(rpc: RPC, id: number, command: string, data: Buffer)
}
interface RPCOutgoingRequest {
readonly rpc: RPC
readonly id: number
readonly command: string
readonly sent: boolean
send(data: Buffer | string, encoding?: BufferEncoding): void
reply(encoding?: BufferEncoding): Promise<Buffer>
createRequestStream(opts?: WritableOptions): RPCOutgoingStream
createResponseStream(opts?: ReadableOptions): RPCIncomingStream
}
declare class RPCOutgoingRequest {
constructor(rpc: RPC, command: string)
}
declare class RPCIncomingStream extends Readable {
constructor(
rpc: RPC,
request: RPCIncomingRequest | RPCOutgoingRequest,
type: typeof constants.type.REQUEST | typeof constants.type.RESPONSE,
opts?: ReadableOptions
)
}
declare class RPCOutgoingStream extends Writable {
constructor(
rpc: RPC,
request: RPCIncomingRequest | RPCOutgoingRequest,
type: typeof constants.type.REQUEST | typeof constants.type.RESPONSE,
opts?: WritableOptions
)
}
interface RPC {
request(command: string): RPCOutgoingRequest
}
declare class RPC {
constructor(stream: PassThrough, onrequest: (req: RPCIncomingRequest) => void)
}
export = RPC