-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
139 lines (103 loc) · 3.01 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import EventEmitter, { EventMap } from 'bare-events'
import { Duplex, DuplexEvents } from 'bare-stream'
import PipeError from './lib/errors'
import constants from './lib/constants'
interface PipeEvents extends DuplexEvents {
connect: []
}
interface PipeOptions {
readBufferSize?: number
allowHalfOpen?: boolean
}
interface PipeConnectOptions {
path?: string
}
interface Pipe<M extends PipeEvents = PipeEvents> extends Duplex<M> {
readonly connecting: boolean
readonly pending: boolean
readonly readyState: 'open' | 'readOnly' | 'writeOnly'
open(fd: number, opts?: { fd?: number }, onconnect?: () => void): this
open(fd: number, onconnect: () => void): this
open(opts: { fd: number }, onconnect?: () => void): this
connect(path: string, opts?: PipeConnectOptions, onconnect?: () => void): this
connect(path: string, onconnect: () => void): this
connect(opts: PipeConnectOptions, onconnect?: () => void): this
ref(): void
unref(): void
}
declare class Pipe<M extends PipeEvents = PipeEvents> extends Duplex<M> {
constructor(path: string | number, opts?: PipeOptions)
constructor(opts?: PipeOptions)
}
interface PipeServerEvents extends EventMap {
close: []
connection: [pipe: Pipe]
err: [err: Error]
listening: []
}
interface PipeServerOptions {
readBufferSize?: number
allowHalfOpen?: boolean
}
interface PipeServerListenOptions {
path?: string
backlog?: number
}
interface PipeServer<M extends PipeServerEvents = PipeServerEvents>
extends EventEmitter<M> {
readonly listening: boolean
address(): string | null
listen(
path: string,
backlog?: number,
opts?: PipeServerListenOptions,
onlistening?: () => void
): this
listen(path: string, backlog: number, onlistening: () => void): this
listen(path: string, onlistening: () => void): this
listen(opts: PipeServerListenOptions): this
close(onclose?: () => void): void
ref(): void
unref(): void
}
declare class PipeServer<
M extends PipeServerEvents = PipeServerEvents
> extends EventEmitter<M> {
constructor(opts?: PipeServerOptions, onconnection?: () => void)
constructor(onconnection: () => void)
}
declare namespace Pipe {
export interface CreateConnectionOptions
extends PipeOptions,
PipeConnectOptions {}
export function createConnection(
path: string,
opts?: CreateConnectionOptions,
onconnect?: () => void
): Pipe
export function createConnection(path: string, onconnect: () => void): Pipe
export function createConnection(
opts: CreateConnectionOptions,
onconnect?: () => void
): Pipe
export function createServer(
opts?: PipeServerOptions,
onconnection?: () => void
): PipeServer
export function pipe(): [read: number, write: number]
export {
type PipeEvents,
type PipeOptions,
Pipe,
type PipeConnectOptions,
type PipeServerEvents,
type PipeServerOptions,
type PipeServerListenOptions,
type PipeServer,
PipeServer as Server,
type PipeError,
PipeError as errors,
constants
}
}
export = Pipe