@types/node 10.12.20 → 10.12.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
node/repl.d.ts ADDED
@@ -0,0 +1,372 @@
1
+ declare module "repl" {
2
+ import { Interface, Completer, AsyncCompleter } from "readline";
3
+ import { Context } from "vm";
4
+ import { InspectOptions } from "util";
5
+
6
+ interface ReplOptions {
7
+ /**
8
+ * The input prompt to display.
9
+ * Default: `"> "`
10
+ */
11
+ prompt?: string;
12
+ /**
13
+ * The `Readable` stream from which REPL input will be read.
14
+ * Default: `process.stdin`
15
+ */
16
+ input?: NodeJS.ReadableStream;
17
+ /**
18
+ * The `Writable` stream to which REPL output will be written.
19
+ * Default: `process.stdout`
20
+ */
21
+ output?: NodeJS.WritableStream;
22
+ /**
23
+ * If `true`, specifies that the output should be treated as a TTY terminal, and have
24
+ * ANSI/VT100 escape codes written to it.
25
+ * Default: checking the value of the `isTTY` property on the output stream upon
26
+ * instantiation.
27
+ */
28
+ terminal?: boolean;
29
+ /**
30
+ * The function to be used when evaluating each given line of input.
31
+ * Default: an async wrapper for the JavaScript `eval()` function. An `eval` function can
32
+ * error with `repl.Recoverable` to indicate the input was incomplete and prompt for
33
+ * additional lines.
34
+ *
35
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_default_evaluation
36
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_custom_evaluation_functions
37
+ */
38
+ eval?: REPLEval;
39
+ /**
40
+ * If `true`, specifies that the default `writer` function should include ANSI color
41
+ * styling to REPL output. If a custom `writer` function is provided then this has no
42
+ * effect.
43
+ * Default: the REPL instance's `terminal` value.
44
+ */
45
+ useColors?: boolean;
46
+ /**
47
+ * If `true`, specifies that the default evaluation function will use the JavaScript
48
+ * `global` as the context as opposed to creating a new separate context for the REPL
49
+ * instance. The node CLI REPL sets this value to `true`.
50
+ * Default: `false`.
51
+ */
52
+ useGlobal?: boolean;
53
+ /**
54
+ * If `true`, specifies that the default writer will not output the return value of a
55
+ * command if it evaluates to `undefined`.
56
+ * Default: `false`.
57
+ */
58
+ ignoreUndefined?: boolean;
59
+ /**
60
+ * The function to invoke to format the output of each command before writing to `output`.
61
+ * Default: a wrapper for `util.inspect`.
62
+ *
63
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_customizing_repl_output
64
+ */
65
+ writer?: REPLWriter;
66
+ /**
67
+ * An optional function used for custom Tab auto completion.
68
+ *
69
+ * @see https://nodejs.org/dist/latest-v11.x/docs/api/readline.html#readline_use_of_the_completer_function
70
+ */
71
+ completer?: Completer | AsyncCompleter;
72
+ /**
73
+ * A flag that specifies whether the default evaluator executes all JavaScript commands in
74
+ * strict mode or default (sloppy) mode.
75
+ * Accepted values are:
76
+ * - `repl.REPL_MODE_SLOPPY` - evaluates expressions in sloppy mode.
77
+ * - `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is equivalent to
78
+ * prefacing every repl statement with `'use strict'`.
79
+ */
80
+ replMode?: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT;
81
+ /**
82
+ * Stop evaluating the current piece of code when `SIGINT` is received, i.e. `Ctrl+C` is
83
+ * pressed. This cannot be used together with a custom `eval` function.
84
+ * Default: `false`.
85
+ */
86
+ breakEvalOnSigint?: boolean;
87
+ }
88
+
89
+ type REPLEval = (this: REPLServer, evalCmd: string, context: Context, file: string, cb: (err: Error | null, result: any) => void) => void;
90
+ type REPLWriter = (this: REPLServer, obj: any) => string;
91
+
92
+ /**
93
+ * This is the default "writer" value, if none is passed in the REPL options,
94
+ * and it can be overridden by custom print functions.
95
+ */
96
+ const writer: REPLWriter & { options: InspectOptions };
97
+
98
+ type REPLCommandAction = (this: REPLServer, text: string) => void;
99
+
100
+ interface REPLCommand {
101
+ /**
102
+ * Help text to be displayed when `.help` is entered.
103
+ */
104
+ help?: string;
105
+ /**
106
+ * The function to execute, optionally accepting a single string argument.
107
+ */
108
+ action: REPLCommandAction;
109
+ }
110
+
111
+ /**
112
+ * Provides a customizable Read-Eval-Print-Loop (REPL).
113
+ *
114
+ * Instances of `repl.REPLServer` will accept individual lines of user input, evaluate those
115
+ * according to a user-defined evaluation function, then output the result. Input and output
116
+ * may be from `stdin` and `stdout`, respectively, or may be connected to any Node.js `stream`.
117
+ *
118
+ * Instances of `repl.REPLServer` support automatic completion of inputs, simplistic Emacs-style
119
+ * line editing, multi-line inputs, ANSI-styled output, saving and restoring current REPL session
120
+ * state, error recovery, and customizable evaluation functions.
121
+ *
122
+ * Instances of `repl.REPLServer` are created using the `repl.start()` method and _should not_
123
+ * be created directly using the JavaScript `new` keyword.
124
+ *
125
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_repl
126
+ */
127
+ class REPLServer extends Interface {
128
+ /**
129
+ * The `vm.Context` provided to the `eval` function to be used for JavaScript
130
+ * evaluation.
131
+ */
132
+ readonly context: Context;
133
+ /**
134
+ * The `Readable` stream from which REPL input will be read.
135
+ */
136
+ readonly inputStream: NodeJS.ReadableStream;
137
+ /**
138
+ * The `Writable` stream to which REPL output will be written.
139
+ */
140
+ readonly outputStream: NodeJS.WritableStream;
141
+ /**
142
+ * The commands registered via `replServer.defineCommand()`.
143
+ */
144
+ readonly commands: { readonly [name: string]: REPLCommand | undefined };
145
+ /**
146
+ * A value indicating whether the REPL is currently in "editor mode".
147
+ *
148
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_commands_and_special_keys
149
+ */
150
+ readonly editorMode: boolean;
151
+ /**
152
+ * A value indicating whether the `_` variable has been assigned.
153
+ *
154
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
155
+ */
156
+ readonly underscoreAssigned: boolean;
157
+ /**
158
+ * The last evaluation result from the REPL (assigned to the `_` variable inside of the REPL).
159
+ *
160
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
161
+ */
162
+ readonly last: any;
163
+ /**
164
+ * A value indicating whether the `_error` variable has been assigned.
165
+ *
166
+ * @since v9.8.0
167
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
168
+ */
169
+ readonly underscoreErrAssigned: boolean;
170
+ /**
171
+ * The last error raised inside the REPL (assigned to the `_error` variable inside of the REPL).
172
+ *
173
+ * @since v9.8.0
174
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
175
+ */
176
+ readonly lastError: any;
177
+ /**
178
+ * Specified in the REPL options, this is the function to be used when evaluating each
179
+ * given line of input. If not specified in the REPL options, this is an async wrapper
180
+ * for the JavaScript `eval()` function.
181
+ */
182
+ readonly eval: REPLEval;
183
+ /**
184
+ * Specified in the REPL options, this is a value indicating whether the default
185
+ * `writer` function should include ANSI color styling to REPL output.
186
+ */
187
+ readonly useColors: boolean;
188
+ /**
189
+ * Specified in the REPL options, this is a value indicating whether the default `eval`
190
+ * function will use the JavaScript `global` as the context as opposed to creating a new
191
+ * separate context for the REPL instance.
192
+ */
193
+ readonly useGlobal: boolean;
194
+ /**
195
+ * Specified in the REPL options, this is a value indicating whether the default `writer`
196
+ * function should output the result of a command if it evaluates to `undefined`.
197
+ */
198
+ readonly ignoreUndefined: boolean;
199
+ /**
200
+ * Specified in the REPL options, this is the function to invoke to format the output of
201
+ * each command before writing to `outputStream`. If not specified in the REPL options,
202
+ * this will be a wrapper for `util.inspect`.
203
+ */
204
+ readonly writer: REPLWriter;
205
+ /**
206
+ * Specified in the REPL options, this is the function to use for custom Tab auto-completion.
207
+ */
208
+ readonly completer: Completer | AsyncCompleter;
209
+ /**
210
+ * Specified in the REPL options, this is a flag that specifies whether the default `eval`
211
+ * function should execute all JavaScript commands in strict mode or default (sloppy) mode.
212
+ * Possible values are:
213
+ * - `repl.REPL_MODE_SLOPPY` - evaluates expressions in sloppy mode.
214
+ * - `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is equivalent to
215
+ * prefacing every repl statement with `'use strict'`.
216
+ */
217
+ readonly replMode: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT;
218
+
219
+ /**
220
+ * NOTE: According to the documentation:
221
+ *
222
+ * > Instances of `repl.REPLServer` are created using the `repl.start()` method and
223
+ * > _should not_ be created directly using the JavaScript `new` keyword.
224
+ *
225
+ * `REPLServer` cannot be subclassed due to implementation specifics in NodeJS.
226
+ *
227
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_class_replserver
228
+ */
229
+ private constructor();
230
+
231
+ /**
232
+ * Used to add new `.`-prefixed commands to the REPL instance. Such commands are invoked
233
+ * by typing a `.` followed by the `keyword`.
234
+ *
235
+ * @param keyword The command keyword (_without_ a leading `.` character).
236
+ * @param cmd The function to invoke when the command is processed.
237
+ *
238
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_replserver_definecommand_keyword_cmd
239
+ */
240
+ defineCommand(keyword: string, cmd: REPLCommandAction | REPLCommand): void;
241
+ /**
242
+ * Readies the REPL instance for input from the user, printing the configured `prompt` to a
243
+ * new line in the `output` and resuming the `input` to accept new input.
244
+ *
245
+ * When multi-line input is being entered, an ellipsis is printed rather than the 'prompt'.
246
+ *
247
+ * This method is primarily intended to be called from within the action function for
248
+ * commands registered using the `replServer.defineCommand()` method.
249
+ *
250
+ * @param preserveCursor When `true`, the cursor placement will not be reset to `0`.
251
+ */
252
+ displayPrompt(preserveCursor?: boolean): void;
253
+ /**
254
+ * Clears any command that has been buffered but not yet executed.
255
+ *
256
+ * This method is primarily intended to be called from within the action function for
257
+ * commands registered using the `replServer.defineCommand()` method.
258
+ *
259
+ * @since v9.0.0
260
+ */
261
+ clearBufferedCommand(): void;
262
+
263
+ /**
264
+ * events.EventEmitter
265
+ * 1. close - inherited from `readline.Interface`
266
+ * 2. line - inherited from `readline.Interface`
267
+ * 3. pause - inherited from `readline.Interface`
268
+ * 4. resume - inherited from `readline.Interface`
269
+ * 5. SIGCONT - inherited from `readline.Interface`
270
+ * 6. SIGINT - inherited from `readline.Interface`
271
+ * 7. SIGTSTP - inherited from `readline.Interface`
272
+ * 8. exit
273
+ * 9. reset
274
+ */
275
+
276
+ addListener(event: string, listener: (...args: any[]) => void): this;
277
+ addListener(event: "close", listener: () => void): this;
278
+ addListener(event: "line", listener: (input: string) => void): this;
279
+ addListener(event: "pause", listener: () => void): this;
280
+ addListener(event: "resume", listener: () => void): this;
281
+ addListener(event: "SIGCONT", listener: () => void): this;
282
+ addListener(event: "SIGINT", listener: () => void): this;
283
+ addListener(event: "SIGTSTP", listener: () => void): this;
284
+ addListener(event: "exit", listener: () => void): this;
285
+ addListener(event: "reset", listener: (context: Context) => void): this;
286
+
287
+ emit(event: string | symbol, ...args: any[]): boolean;
288
+ emit(event: "close"): boolean;
289
+ emit(event: "line", input: string): boolean;
290
+ emit(event: "pause"): boolean;
291
+ emit(event: "resume"): boolean;
292
+ emit(event: "SIGCONT"): boolean;
293
+ emit(event: "SIGINT"): boolean;
294
+ emit(event: "SIGTSTP"): boolean;
295
+ emit(event: "exit"): boolean;
296
+ emit(event: "reset", context: Context): boolean;
297
+
298
+ on(event: string, listener: (...args: any[]) => void): this;
299
+ on(event: "close", listener: () => void): this;
300
+ on(event: "line", listener: (input: string) => void): this;
301
+ on(event: "pause", listener: () => void): this;
302
+ on(event: "resume", listener: () => void): this;
303
+ on(event: "SIGCONT", listener: () => void): this;
304
+ on(event: "SIGINT", listener: () => void): this;
305
+ on(event: "SIGTSTP", listener: () => void): this;
306
+ on(event: "exit", listener: () => void): this;
307
+ on(event: "reset", listener: (context: Context) => void): this;
308
+
309
+ once(event: string, listener: (...args: any[]) => void): this;
310
+ once(event: "close", listener: () => void): this;
311
+ once(event: "line", listener: (input: string) => void): this;
312
+ once(event: "pause", listener: () => void): this;
313
+ once(event: "resume", listener: () => void): this;
314
+ once(event: "SIGCONT", listener: () => void): this;
315
+ once(event: "SIGINT", listener: () => void): this;
316
+ once(event: "SIGTSTP", listener: () => void): this;
317
+ once(event: "exit", listener: () => void): this;
318
+ once(event: "reset", listener: (context: Context) => void): this;
319
+
320
+ prependListener(event: string, listener: (...args: any[]) => void): this;
321
+ prependListener(event: "close", listener: () => void): this;
322
+ prependListener(event: "line", listener: (input: string) => void): this;
323
+ prependListener(event: "pause", listener: () => void): this;
324
+ prependListener(event: "resume", listener: () => void): this;
325
+ prependListener(event: "SIGCONT", listener: () => void): this;
326
+ prependListener(event: "SIGINT", listener: () => void): this;
327
+ prependListener(event: "SIGTSTP", listener: () => void): this;
328
+ prependListener(event: "exit", listener: () => void): this;
329
+ prependListener(event: "reset", listener: (context: Context) => void): this;
330
+
331
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
332
+ prependOnceListener(event: "close", listener: () => void): this;
333
+ prependOnceListener(event: "line", listener: (input: string) => void): this;
334
+ prependOnceListener(event: "pause", listener: () => void): this;
335
+ prependOnceListener(event: "resume", listener: () => void): this;
336
+ prependOnceListener(event: "SIGCONT", listener: () => void): this;
337
+ prependOnceListener(event: "SIGINT", listener: () => void): this;
338
+ prependOnceListener(event: "SIGTSTP", listener: () => void): this;
339
+ prependOnceListener(event: "exit", listener: () => void): this;
340
+ prependOnceListener(event: "reset", listener: (context: Context) => void): this;
341
+ }
342
+
343
+ /**
344
+ * A flag passed in the REPL options. Evaluates expressions in sloppy mode.
345
+ */
346
+ export const REPL_MODE_SLOPPY: symbol; // TODO: unique symbol
347
+
348
+ /**
349
+ * A flag passed in the REPL options. Evaluates expressions in strict mode.
350
+ * This is equivalent to prefacing every repl statement with `'use strict'`.
351
+ */
352
+ export const REPL_MODE_STRICT: symbol; // TODO: unique symbol
353
+
354
+ /**
355
+ * Creates and starts a `repl.REPLServer` instance.
356
+ *
357
+ * @param options The options for the `REPLServer`. If `options` is a string, then it specifies
358
+ * the input prompt.
359
+ */
360
+ function start(options?: string | ReplOptions): REPLServer;
361
+
362
+ /**
363
+ * Indicates a recoverable error that a `REPLServer` can use to support multi-line input.
364
+ *
365
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_recoverable_errors
366
+ */
367
+ class Recoverable extends SyntaxError {
368
+ err: Error;
369
+
370
+ constructor(err: Error);
371
+ }
372
+ }
node/stream.d.ts ADDED
@@ -0,0 +1,294 @@
1
+ declare module "stream" {
2
+ import * as events from "events";
3
+
4
+ class internal extends events.EventEmitter {
5
+ pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
6
+ }
7
+
8
+ namespace internal {
9
+ class Stream extends internal { }
10
+
11
+ interface ReadableOptions {
12
+ highWaterMark?: number;
13
+ encoding?: string;
14
+ objectMode?: boolean;
15
+ read?(this: Readable, size: number): void;
16
+ destroy?(this: Readable, error: Error | null, callback: (error: Error | null) => void): void;
17
+ }
18
+
19
+ class Readable extends Stream implements NodeJS.ReadableStream {
20
+ readable: boolean;
21
+ readonly readableHighWaterMark: number;
22
+ readonly readableLength: number;
23
+ constructor(opts?: ReadableOptions);
24
+ _read(size: number): void;
25
+ read(size?: number): any;
26
+ setEncoding(encoding: string): this;
27
+ pause(): this;
28
+ resume(): this;
29
+ isPaused(): boolean;
30
+ unpipe(destination?: NodeJS.WritableStream): this;
31
+ unshift(chunk: any): void;
32
+ wrap(oldStream: NodeJS.ReadableStream): this;
33
+ push(chunk: any, encoding?: string): boolean;
34
+ _destroy(error: Error | null, callback: (error: Error | null) => void): void;
35
+ destroy(error?: Error): void;
36
+
37
+ /**
38
+ * Event emitter
39
+ * The defined events on documents including:
40
+ * 1. close
41
+ * 2. data
42
+ * 3. end
43
+ * 4. readable
44
+ * 5. error
45
+ */
46
+ addListener(event: "close", listener: () => void): this;
47
+ addListener(event: "data", listener: (chunk: any) => void): this;
48
+ addListener(event: "end", listener: () => void): this;
49
+ addListener(event: "readable", listener: () => void): this;
50
+ addListener(event: "error", listener: (err: Error) => void): this;
51
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
52
+
53
+ emit(event: "close"): boolean;
54
+ emit(event: "data", chunk: any): boolean;
55
+ emit(event: "end"): boolean;
56
+ emit(event: "readable"): boolean;
57
+ emit(event: "error", err: Error): boolean;
58
+ emit(event: string | symbol, ...args: any[]): boolean;
59
+
60
+ on(event: "close", listener: () => void): this;
61
+ on(event: "data", listener: (chunk: any) => void): this;
62
+ on(event: "end", listener: () => void): this;
63
+ on(event: "readable", listener: () => void): this;
64
+ on(event: "error", listener: (err: Error) => void): this;
65
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
66
+
67
+ once(event: "close", listener: () => void): this;
68
+ once(event: "data", listener: (chunk: any) => void): this;
69
+ once(event: "end", listener: () => void): this;
70
+ once(event: "readable", listener: () => void): this;
71
+ once(event: "error", listener: (err: Error) => void): this;
72
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
73
+
74
+ prependListener(event: "close", listener: () => void): this;
75
+ prependListener(event: "data", listener: (chunk: any) => void): this;
76
+ prependListener(event: "end", listener: () => void): this;
77
+ prependListener(event: "readable", listener: () => void): this;
78
+ prependListener(event: "error", listener: (err: Error) => void): this;
79
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
80
+
81
+ prependOnceListener(event: "close", listener: () => void): this;
82
+ prependOnceListener(event: "data", listener: (chunk: any) => void): this;
83
+ prependOnceListener(event: "end", listener: () => void): this;
84
+ prependOnceListener(event: "readable", listener: () => void): this;
85
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
86
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
87
+
88
+ removeListener(event: "close", listener: () => void): this;
89
+ removeListener(event: "data", listener: (chunk: any) => void): this;
90
+ removeListener(event: "end", listener: () => void): this;
91
+ removeListener(event: "readable", listener: () => void): this;
92
+ removeListener(event: "error", listener: (err: Error) => void): this;
93
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
94
+
95
+ [Symbol.asyncIterator](): AsyncIterableIterator<any>;
96
+ }
97
+
98
+ interface WritableOptions {
99
+ highWaterMark?: number;
100
+ decodeStrings?: boolean;
101
+ objectMode?: boolean;
102
+ write?(this: Writable, chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
103
+ writev?(this: Writable, chunks: Array<{ chunk: any, encoding: string }>, callback: (error?: Error | null) => void): void;
104
+ destroy?(this: Writable, error: Error | null, callback: (error: Error | null) => void): void;
105
+ final?(this: Writable, callback: (error?: Error | null) => void): void;
106
+ }
107
+
108
+ class Writable extends Stream implements NodeJS.WritableStream {
109
+ writable: boolean;
110
+ readonly writableHighWaterMark: number;
111
+ readonly writableLength: number;
112
+ constructor(opts?: WritableOptions);
113
+ _write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
114
+ _writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (error?: Error | null) => void): void;
115
+ _destroy(error: Error | null, callback: (error: Error | null) => void): void;
116
+ _final(callback: (error?: Error | null) => void): void;
117
+ write(chunk: any, cb?: (error: Error | null | undefined) => void): boolean;
118
+ write(chunk: any, encoding?: string, cb?: (error: Error | null | undefined) => void): boolean;
119
+ setDefaultEncoding(encoding: string): this;
120
+ end(cb?: () => void): void;
121
+ end(chunk: any, cb?: () => void): void;
122
+ end(chunk: any, encoding?: string, cb?: () => void): void;
123
+ cork(): void;
124
+ uncork(): void;
125
+ destroy(error?: Error): void;
126
+
127
+ /**
128
+ * Event emitter
129
+ * The defined events on documents including:
130
+ * 1. close
131
+ * 2. drain
132
+ * 3. error
133
+ * 4. finish
134
+ * 5. pipe
135
+ * 6. unpipe
136
+ */
137
+ addListener(event: "close", listener: () => void): this;
138
+ addListener(event: "drain", listener: () => void): this;
139
+ addListener(event: "error", listener: (err: Error) => void): this;
140
+ addListener(event: "finish", listener: () => void): this;
141
+ addListener(event: "pipe", listener: (src: Readable) => void): this;
142
+ addListener(event: "unpipe", listener: (src: Readable) => void): this;
143
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
144
+
145
+ emit(event: "close"): boolean;
146
+ emit(event: "drain"): boolean;
147
+ emit(event: "error", err: Error): boolean;
148
+ emit(event: "finish"): boolean;
149
+ emit(event: "pipe", src: Readable): boolean;
150
+ emit(event: "unpipe", src: Readable): boolean;
151
+ emit(event: string | symbol, ...args: any[]): boolean;
152
+
153
+ on(event: "close", listener: () => void): this;
154
+ on(event: "drain", listener: () => void): this;
155
+ on(event: "error", listener: (err: Error) => void): this;
156
+ on(event: "finish", listener: () => void): this;
157
+ on(event: "pipe", listener: (src: Readable) => void): this;
158
+ on(event: "unpipe", listener: (src: Readable) => void): this;
159
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
160
+
161
+ once(event: "close", listener: () => void): this;
162
+ once(event: "drain", listener: () => void): this;
163
+ once(event: "error", listener: (err: Error) => void): this;
164
+ once(event: "finish", listener: () => void): this;
165
+ once(event: "pipe", listener: (src: Readable) => void): this;
166
+ once(event: "unpipe", listener: (src: Readable) => void): this;
167
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
168
+
169
+ prependListener(event: "close", listener: () => void): this;
170
+ prependListener(event: "drain", listener: () => void): this;
171
+ prependListener(event: "error", listener: (err: Error) => void): this;
172
+ prependListener(event: "finish", listener: () => void): this;
173
+ prependListener(event: "pipe", listener: (src: Readable) => void): this;
174
+ prependListener(event: "unpipe", listener: (src: Readable) => void): this;
175
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
176
+
177
+ prependOnceListener(event: "close", listener: () => void): this;
178
+ prependOnceListener(event: "drain", listener: () => void): this;
179
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
180
+ prependOnceListener(event: "finish", listener: () => void): this;
181
+ prependOnceListener(event: "pipe", listener: (src: Readable) => void): this;
182
+ prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this;
183
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
184
+
185
+ removeListener(event: "close", listener: () => void): this;
186
+ removeListener(event: "drain", listener: () => void): this;
187
+ removeListener(event: "error", listener: (err: Error) => void): this;
188
+ removeListener(event: "finish", listener: () => void): this;
189
+ removeListener(event: "pipe", listener: (src: Readable) => void): this;
190
+ removeListener(event: "unpipe", listener: (src: Readable) => void): this;
191
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
192
+ }
193
+
194
+ interface DuplexOptions extends ReadableOptions, WritableOptions {
195
+ allowHalfOpen?: boolean;
196
+ readableObjectMode?: boolean;
197
+ writableObjectMode?: boolean;
198
+ read?(this: Duplex, size: number): void;
199
+ write?(this: Duplex, chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
200
+ writev?(this: Duplex, chunks: Array<{ chunk: any, encoding: string }>, callback: (error?: Error | null) => void): void;
201
+ final?(this: Duplex, callback: (error?: Error | null) => void): void;
202
+ destroy?(this: Duplex, error: Error | null, callback: (error: Error | null) => void): void;
203
+ }
204
+
205
+ // Note: Duplex extends both Readable and Writable.
206
+ class Duplex extends Readable implements Writable {
207
+ writable: boolean;
208
+ readonly writableHighWaterMark: number;
209
+ readonly writableLength: number;
210
+ constructor(opts?: DuplexOptions);
211
+ _write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
212
+ _writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (error?: Error | null) => void): void;
213
+ _destroy(error: Error | null, callback: (error: Error | null) => void): void;
214
+ _final(callback: (error?: Error | null) => void): void;
215
+ write(chunk: any, cb?: (error: Error | null | undefined) => void): boolean;
216
+ write(chunk: any, encoding?: string, cb?: (error: Error | null | undefined) => void): boolean;
217
+ setDefaultEncoding(encoding: string): this;
218
+ end(cb?: () => void): void;
219
+ end(chunk: any, cb?: () => void): void;
220
+ end(chunk: any, encoding?: string, cb?: () => void): void;
221
+ cork(): void;
222
+ uncork(): void;
223
+ }
224
+
225
+ type TransformCallback = (error?: Error, data?: any) => void;
226
+
227
+ interface TransformOptions extends DuplexOptions {
228
+ read?(this: Transform, size: number): void;
229
+ write?(this: Transform, chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
230
+ writev?(this: Transform, chunks: Array<{ chunk: any, encoding: string }>, callback: (error?: Error | null) => void): void;
231
+ final?(this: Transform, callback: (error?: Error | null) => void): void;
232
+ destroy?(this: Transform, error: Error | null, callback: (error: Error | null) => void): void;
233
+ transform?(this: Transform, chunk: any, encoding: string, callback: TransformCallback): void;
234
+ flush?(this: Transform, callback: TransformCallback): void;
235
+ }
236
+
237
+ class Transform extends Duplex {
238
+ constructor(opts?: TransformOptions);
239
+ _transform(chunk: any, encoding: string, callback: TransformCallback): void;
240
+ _flush(callback: TransformCallback): void;
241
+ }
242
+
243
+ class PassThrough extends Transform { }
244
+
245
+ function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, callback: (err?: NodeJS.ErrnoException) => void): () => void;
246
+ namespace finished {
247
+ function __promisify__(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream): Promise<void>;
248
+ }
249
+
250
+ function pipeline<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: T, callback?: (err: NodeJS.ErrnoException) => void): T;
251
+ function pipeline<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: T, callback?: (err: NodeJS.ErrnoException) => void): T;
252
+ function pipeline<T extends NodeJS.WritableStream>(
253
+ stream1: NodeJS.ReadableStream,
254
+ stream2: NodeJS.ReadWriteStream,
255
+ stream3: NodeJS.ReadWriteStream,
256
+ stream4: T,
257
+ callback?: (err: NodeJS.ErrnoException) => void,
258
+ ): T;
259
+ function pipeline<T extends NodeJS.WritableStream>(
260
+ stream1: NodeJS.ReadableStream,
261
+ stream2: NodeJS.ReadWriteStream,
262
+ stream3: NodeJS.ReadWriteStream,
263
+ stream4: NodeJS.ReadWriteStream,
264
+ stream5: T,
265
+ callback?: (err: NodeJS.ErrnoException) => void,
266
+ ): T;
267
+ function pipeline(streams: Array<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>, callback?: (err: NodeJS.ErrnoException) => void): NodeJS.WritableStream;
268
+ function pipeline(
269
+ stream1: NodeJS.ReadableStream,
270
+ stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
271
+ ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | ((err: NodeJS.ErrnoException) => void)>,
272
+ ): NodeJS.WritableStream;
273
+ namespace pipeline {
274
+ function __promisify__(stream1: NodeJS.ReadableStream, stream2: NodeJS.WritableStream): Promise<void>;
275
+ function __promisify__(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: NodeJS.WritableStream): Promise<void>;
276
+ function __promisify__(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: NodeJS.ReadWriteStream, stream4: NodeJS.WritableStream): Promise<void>;
277
+ function __promisify__(
278
+ stream1: NodeJS.ReadableStream,
279
+ stream2: NodeJS.ReadWriteStream,
280
+ stream3: NodeJS.ReadWriteStream,
281
+ stream4: NodeJS.ReadWriteStream,
282
+ stream5: NodeJS.WritableStream,
283
+ ): Promise<void>;
284
+ function __promisify__(streams: Array<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>): Promise<void>;
285
+ function __promisify__(
286
+ stream1: NodeJS.ReadableStream,
287
+ stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
288
+ ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream>,
289
+ ): Promise<void>;
290
+ }
291
+ }
292
+
293
+ export = internal;
294
+ }
@@ -0,0 +1,9 @@
1
+ declare module "string_decoder" {
2
+ interface NodeStringDecoder {
3
+ write(buffer: Buffer): string;
4
+ end(buffer?: Buffer): string;
5
+ }
6
+ const StringDecoder: {
7
+ new(encoding?: string): NodeStringDecoder;
8
+ };
9
+ }