@types/node 16.4.1 → 16.4.5

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 CHANGED
@@ -1,8 +1,17 @@
1
+ /**
2
+ * The `repl` module provides a Read-Eval-Print-Loop (REPL) implementation that
3
+ * is available both as a standalone program or includible in other applications.
4
+ * It can be accessed using:
5
+ *
6
+ * ```js
7
+ * const repl = require('repl');
8
+ * ```
9
+ * @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/repl.js)
10
+ */
1
11
  declare module 'repl' {
2
12
  import { Interface, Completer, AsyncCompleter } from 'node:readline';
3
13
  import { Context } from 'node:vm';
4
14
  import { InspectOptions } from 'node:util';
5
-
6
15
  interface ReplOptions {
7
16
  /**
8
17
  * The input prompt to display.
@@ -90,18 +99,16 @@ declare module 'repl' {
90
99
  */
91
100
  breakEvalOnSigint?: boolean | undefined;
92
101
  }
93
-
94
102
  type REPLEval = (this: REPLServer, evalCmd: string, context: Context, file: string, cb: (err: Error | null, result: any) => void) => void;
95
103
  type REPLWriter = (this: REPLServer, obj: any) => string;
96
-
97
104
  /**
98
105
  * This is the default "writer" value, if none is passed in the REPL options,
99
106
  * and it can be overridden by custom print functions.
100
107
  */
101
- const writer: REPLWriter & { options: InspectOptions };
102
-
108
+ const writer: REPLWriter & {
109
+ options: InspectOptions;
110
+ };
103
111
  type REPLCommandAction = (this: REPLServer, text: string) => void;
104
-
105
112
  interface REPLCommand {
106
113
  /**
107
114
  * Help text to be displayed when `.help` is entered.
@@ -112,22 +119,19 @@ declare module 'repl' {
112
119
  */
113
120
  action: REPLCommandAction;
114
121
  }
115
-
116
122
  /**
117
- * Provides a customizable Read-Eval-Print-Loop (REPL).
123
+ * Instances of `repl.REPLServer` are created using the {@link start} method
124
+ * or directly using the JavaScript `new` keyword.
118
125
  *
119
- * Instances of `repl.REPLServer` will accept individual lines of user input, evaluate those
120
- * according to a user-defined evaluation function, then output the result. Input and output
121
- * may be from `stdin` and `stdout`, respectively, or may be connected to any Node.js `stream`.
126
+ * ```js
127
+ * const repl = require('repl');
122
128
  *
123
- * Instances of `repl.REPLServer` support automatic completion of inputs, simplistic Emacs-style
124
- * line editing, multi-line inputs, ANSI-styled output, saving and restoring current REPL session
125
- * state, error recovery, and customizable evaluation functions.
129
+ * const options = { useColors: true };
126
130
  *
127
- * Instances of `repl.REPLServer` are created using the `repl.start()` method and _should not_
128
- * be created directly using the JavaScript `new` keyword.
129
- *
130
- * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_repl
131
+ * const firstInstance = repl.start(options);
132
+ * const secondInstance = new repl.REPLServer(options);
133
+ * ```
134
+ * @since v0.1.91
131
135
  */
132
136
  class REPLServer extends Interface {
133
137
  /**
@@ -228,7 +232,6 @@ declare module 'repl' {
228
232
  * prefacing every repl statement with `'use strict'`.
229
233
  */
230
234
  readonly replMode: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT;
231
-
232
235
  /**
233
236
  * NOTE: According to the documentation:
234
237
  *
@@ -240,49 +243,76 @@ declare module 'repl' {
240
243
  * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_class_replserver
241
244
  */
242
245
  private constructor();
243
-
244
246
  /**
245
- * Used to add new `.`-prefixed commands to the REPL instance. Such commands are invoked
246
- * by typing a `.` followed by the `keyword`.
247
+ * The `replServer.defineCommand()` method is used to add new `.`\-prefixed commands
248
+ * to the REPL instance. Such commands are invoked by typing a `.` followed by the`keyword`. The `cmd` is either a `Function` or an `Object` with the following
249
+ * properties:
247
250
  *
248
- * @param keyword The command keyword (_without_ a leading `.` character).
249
- * @param cmd The function to invoke when the command is processed.
251
+ * The following example shows two new commands added to the REPL instance:
252
+ *
253
+ * ```js
254
+ * const repl = require('repl');
255
+ *
256
+ * const replServer = repl.start({ prompt: '> ' });
257
+ * replServer.defineCommand('sayhello', {
258
+ * help: 'Say hello',
259
+ * action(name) {
260
+ * this.clearBufferedCommand();
261
+ * console.log(`Hello, ${name}!`);
262
+ * this.displayPrompt();
263
+ * }
264
+ * });
265
+ * replServer.defineCommand('saybye', function saybye() {
266
+ * console.log('Goodbye!');
267
+ * this.close();
268
+ * });
269
+ * ```
270
+ *
271
+ * The new commands can then be used from within the REPL instance:
250
272
  *
251
- * @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_replserver_definecommand_keyword_cmd
273
+ * ```console
274
+ * > .sayhello Node.js User
275
+ * Hello, Node.js User!
276
+ * > .saybye
277
+ * Goodbye!
278
+ * ```
279
+ * @since v0.3.0
280
+ * @param keyword The command keyword (*without* a leading `.` character).
281
+ * @param cmd The function to invoke when the command is processed.
252
282
  */
253
283
  defineCommand(keyword: string, cmd: REPLCommandAction | REPLCommand): void;
254
284
  /**
255
- * Readies the REPL instance for input from the user, printing the configured `prompt` to a
256
- * new line in the `output` and resuming the `input` to accept new input.
285
+ * The `replServer.displayPrompt()` method readies the REPL instance for input
286
+ * from the user, printing the configured `prompt` to a new line in the `output`and resuming the `input` to accept new input.
257
287
  *
258
- * When multi-line input is being entered, an ellipsis is printed rather than the 'prompt'.
288
+ * When multi-line input is being entered, an ellipsis is printed rather than the
289
+ * 'prompt'.
259
290
  *
260
- * This method is primarily intended to be called from within the action function for
261
- * commands registered using the `replServer.defineCommand()` method.
291
+ * When `preserveCursor` is `true`, the cursor placement will not be reset to `0`.
262
292
  *
263
- * @param preserveCursor When `true`, the cursor placement will not be reset to `0`.
293
+ * The `replServer.displayPrompt` method is primarily intended to be called from
294
+ * within the action function for commands registered using the`replServer.defineCommand()` method.
295
+ * @since v0.1.91
264
296
  */
265
297
  displayPrompt(preserveCursor?: boolean): void;
266
298
  /**
267
- * Clears any command that has been buffered but not yet executed.
268
- *
269
- * This method is primarily intended to be called from within the action function for
270
- * commands registered using the `replServer.defineCommand()` method.
271
- *
299
+ * The `replServer.clearBufferedCommand()` method clears any command that has been
300
+ * buffered but not yet executed. This method is primarily intended to be
301
+ * called from within the action function for commands registered using the`replServer.defineCommand()` method.
272
302
  * @since v9.0.0
273
303
  */
274
304
  clearBufferedCommand(): void;
275
-
276
305
  /**
277
306
  * Initializes a history log file for the REPL instance. When executing the
278
- * Node.js binary and using the command line REPL, a history file is initialized
307
+ * Node.js binary and using the command-line REPL, a history file is initialized
279
308
  * by default. However, this is not the case when creating a REPL
280
309
  * programmatically. Use this method to initialize a history log file when working
281
310
  * with REPL instances programmatically.
282
- * @param path The path to the history file
311
+ * @since v11.10.0
312
+ * @param historyPath the path to the history file
313
+ * @param callback called when history writes are ready or upon error
283
314
  */
284
- setupHistory(path: string, cb: (err: Error | null, repl: this) => void): void;
285
-
315
+ setupHistory(path: string, callback: (err: Error | null, repl: this) => void): void;
286
316
  /**
287
317
  * events.EventEmitter
288
318
  * 1. close - inherited from `readline.Interface`
@@ -295,93 +325,90 @@ declare module 'repl' {
295
325
  * 8. exit
296
326
  * 9. reset
297
327
  */
298
-
299
328
  addListener(event: string, listener: (...args: any[]) => void): this;
300
- addListener(event: "close", listener: () => void): this;
301
- addListener(event: "line", listener: (input: string) => void): this;
302
- addListener(event: "pause", listener: () => void): this;
303
- addListener(event: "resume", listener: () => void): this;
304
- addListener(event: "SIGCONT", listener: () => void): this;
305
- addListener(event: "SIGINT", listener: () => void): this;
306
- addListener(event: "SIGTSTP", listener: () => void): this;
307
- addListener(event: "exit", listener: () => void): this;
308
- addListener(event: "reset", listener: (context: Context) => void): this;
309
-
329
+ addListener(event: 'close', listener: () => void): this;
330
+ addListener(event: 'line', listener: (input: string) => void): this;
331
+ addListener(event: 'pause', listener: () => void): this;
332
+ addListener(event: 'resume', listener: () => void): this;
333
+ addListener(event: 'SIGCONT', listener: () => void): this;
334
+ addListener(event: 'SIGINT', listener: () => void): this;
335
+ addListener(event: 'SIGTSTP', listener: () => void): this;
336
+ addListener(event: 'exit', listener: () => void): this;
337
+ addListener(event: 'reset', listener: (context: Context) => void): this;
310
338
  emit(event: string | symbol, ...args: any[]): boolean;
311
- emit(event: "close"): boolean;
312
- emit(event: "line", input: string): boolean;
313
- emit(event: "pause"): boolean;
314
- emit(event: "resume"): boolean;
315
- emit(event: "SIGCONT"): boolean;
316
- emit(event: "SIGINT"): boolean;
317
- emit(event: "SIGTSTP"): boolean;
318
- emit(event: "exit"): boolean;
319
- emit(event: "reset", context: Context): boolean;
320
-
339
+ emit(event: 'close'): boolean;
340
+ emit(event: 'line', input: string): boolean;
341
+ emit(event: 'pause'): boolean;
342
+ emit(event: 'resume'): boolean;
343
+ emit(event: 'SIGCONT'): boolean;
344
+ emit(event: 'SIGINT'): boolean;
345
+ emit(event: 'SIGTSTP'): boolean;
346
+ emit(event: 'exit'): boolean;
347
+ emit(event: 'reset', context: Context): boolean;
321
348
  on(event: string, listener: (...args: any[]) => void): this;
322
- on(event: "close", listener: () => void): this;
323
- on(event: "line", listener: (input: string) => void): this;
324
- on(event: "pause", listener: () => void): this;
325
- on(event: "resume", listener: () => void): this;
326
- on(event: "SIGCONT", listener: () => void): this;
327
- on(event: "SIGINT", listener: () => void): this;
328
- on(event: "SIGTSTP", listener: () => void): this;
329
- on(event: "exit", listener: () => void): this;
330
- on(event: "reset", listener: (context: Context) => void): this;
331
-
349
+ on(event: 'close', listener: () => void): this;
350
+ on(event: 'line', listener: (input: string) => void): this;
351
+ on(event: 'pause', listener: () => void): this;
352
+ on(event: 'resume', listener: () => void): this;
353
+ on(event: 'SIGCONT', listener: () => void): this;
354
+ on(event: 'SIGINT', listener: () => void): this;
355
+ on(event: 'SIGTSTP', listener: () => void): this;
356
+ on(event: 'exit', listener: () => void): this;
357
+ on(event: 'reset', listener: (context: Context) => void): this;
332
358
  once(event: string, listener: (...args: any[]) => void): this;
333
- once(event: "close", listener: () => void): this;
334
- once(event: "line", listener: (input: string) => void): this;
335
- once(event: "pause", listener: () => void): this;
336
- once(event: "resume", listener: () => void): this;
337
- once(event: "SIGCONT", listener: () => void): this;
338
- once(event: "SIGINT", listener: () => void): this;
339
- once(event: "SIGTSTP", listener: () => void): this;
340
- once(event: "exit", listener: () => void): this;
341
- once(event: "reset", listener: (context: Context) => void): this;
342
-
359
+ once(event: 'close', listener: () => void): this;
360
+ once(event: 'line', listener: (input: string) => void): this;
361
+ once(event: 'pause', listener: () => void): this;
362
+ once(event: 'resume', listener: () => void): this;
363
+ once(event: 'SIGCONT', listener: () => void): this;
364
+ once(event: 'SIGINT', listener: () => void): this;
365
+ once(event: 'SIGTSTP', listener: () => void): this;
366
+ once(event: 'exit', listener: () => void): this;
367
+ once(event: 'reset', listener: (context: Context) => void): this;
343
368
  prependListener(event: string, listener: (...args: any[]) => void): this;
344
- prependListener(event: "close", listener: () => void): this;
345
- prependListener(event: "line", listener: (input: string) => void): this;
346
- prependListener(event: "pause", listener: () => void): this;
347
- prependListener(event: "resume", listener: () => void): this;
348
- prependListener(event: "SIGCONT", listener: () => void): this;
349
- prependListener(event: "SIGINT", listener: () => void): this;
350
- prependListener(event: "SIGTSTP", listener: () => void): this;
351
- prependListener(event: "exit", listener: () => void): this;
352
- prependListener(event: "reset", listener: (context: Context) => void): this;
353
-
369
+ prependListener(event: 'close', listener: () => void): this;
370
+ prependListener(event: 'line', listener: (input: string) => void): this;
371
+ prependListener(event: 'pause', listener: () => void): this;
372
+ prependListener(event: 'resume', listener: () => void): this;
373
+ prependListener(event: 'SIGCONT', listener: () => void): this;
374
+ prependListener(event: 'SIGINT', listener: () => void): this;
375
+ prependListener(event: 'SIGTSTP', listener: () => void): this;
376
+ prependListener(event: 'exit', listener: () => void): this;
377
+ prependListener(event: 'reset', listener: (context: Context) => void): this;
354
378
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
355
- prependOnceListener(event: "close", listener: () => void): this;
356
- prependOnceListener(event: "line", listener: (input: string) => void): this;
357
- prependOnceListener(event: "pause", listener: () => void): this;
358
- prependOnceListener(event: "resume", listener: () => void): this;
359
- prependOnceListener(event: "SIGCONT", listener: () => void): this;
360
- prependOnceListener(event: "SIGINT", listener: () => void): this;
361
- prependOnceListener(event: "SIGTSTP", listener: () => void): this;
362
- prependOnceListener(event: "exit", listener: () => void): this;
363
- prependOnceListener(event: "reset", listener: (context: Context) => void): this;
379
+ prependOnceListener(event: 'close', listener: () => void): this;
380
+ prependOnceListener(event: 'line', listener: (input: string) => void): this;
381
+ prependOnceListener(event: 'pause', listener: () => void): this;
382
+ prependOnceListener(event: 'resume', listener: () => void): this;
383
+ prependOnceListener(event: 'SIGCONT', listener: () => void): this;
384
+ prependOnceListener(event: 'SIGINT', listener: () => void): this;
385
+ prependOnceListener(event: 'SIGTSTP', listener: () => void): this;
386
+ prependOnceListener(event: 'exit', listener: () => void): this;
387
+ prependOnceListener(event: 'reset', listener: (context: Context) => void): this;
364
388
  }
365
-
366
389
  /**
367
390
  * A flag passed in the REPL options. Evaluates expressions in sloppy mode.
368
391
  */
369
392
  const REPL_MODE_SLOPPY: unique symbol;
370
-
371
393
  /**
372
394
  * A flag passed in the REPL options. Evaluates expressions in strict mode.
373
395
  * This is equivalent to prefacing every repl statement with `'use strict'`.
374
396
  */
375
397
  const REPL_MODE_STRICT: unique symbol;
376
-
377
398
  /**
378
- * Creates and starts a `repl.REPLServer` instance.
399
+ * The `repl.start()` method creates and starts a {@link REPLServer} instance.
400
+ *
401
+ * If `options` is a string, then it specifies the input prompt:
402
+ *
403
+ * ```js
404
+ * const repl = require('repl');
379
405
  *
380
- * @param options The options for the `REPLServer`. If `options` is a string, then it specifies
381
- * the input prompt.
406
+ * // a Unix style prompt
407
+ * repl.start('$ ');
408
+ * ```
409
+ * @since v0.1.91
382
410
  */
383
411
  function start(options?: string | ReplOptions): REPLServer;
384
-
385
412
  /**
386
413
  * Indicates a recoverable error that a `REPLServer` can use to support multi-line input.
387
414
  *
@@ -389,11 +416,9 @@ declare module 'repl' {
389
416
  */
390
417
  class Recoverable extends SyntaxError {
391
418
  err: Error;
392
-
393
419
  constructor(err: Error);
394
420
  }
395
421
  }
396
-
397
422
  declare module 'node:repl' {
398
423
  export * from 'repl';
399
424
  }
node/stream/promises.d.ts CHANGED
@@ -1,71 +1,42 @@
1
- declare module "stream/promises" {
2
- import { FinishedOptions, PipelineSource, PipelineTransform,
3
- PipelineDestination, PipelinePromise, PipelineOptions } from "node:stream";
4
-
1
+ declare module 'stream/promises' {
2
+ import { FinishedOptions, PipelineSource, PipelineTransform, PipelineDestination, PipelinePromise, PipelineOptions } from 'node:stream';
5
3
  function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, options?: FinishedOptions): Promise<void>;
6
-
7
- function pipeline<A extends PipelineSource<any>,
8
- B extends PipelineDestination<A, any>>(
9
- source: A,
10
- destination: B,
11
- options?: PipelineOptions
12
- ): PipelinePromise<B>;
13
- function pipeline<A extends PipelineSource<any>,
14
- T1 extends PipelineTransform<A, any>,
15
- B extends PipelineDestination<T1, any>>(
4
+ function pipeline<A extends PipelineSource<any>, B extends PipelineDestination<A, any>>(source: A, destination: B, options?: PipelineOptions): PipelinePromise<B>;
5
+ function pipeline<A extends PipelineSource<any>, T1 extends PipelineTransform<A, any>, B extends PipelineDestination<T1, any>>(
16
6
  source: A,
17
7
  transform1: T1,
18
8
  destination: B,
19
9
  options?: PipelineOptions
20
10
  ): PipelinePromise<B>;
21
- function pipeline<A extends PipelineSource<any>,
22
- T1 extends PipelineTransform<A, any>,
23
- T2 extends PipelineTransform<T1, any>,
24
- B extends PipelineDestination<T2, any>>(
11
+ function pipeline<A extends PipelineSource<any>, T1 extends PipelineTransform<A, any>, T2 extends PipelineTransform<T1, any>, B extends PipelineDestination<T2, any>>(
25
12
  source: A,
26
13
  transform1: T1,
27
14
  transform2: T2,
28
15
  destination: B,
29
16
  options?: PipelineOptions
30
17
  ): PipelinePromise<B>;
31
- function pipeline<A extends PipelineSource<any>,
18
+ function pipeline<
19
+ A extends PipelineSource<any>,
32
20
  T1 extends PipelineTransform<A, any>,
33
21
  T2 extends PipelineTransform<T1, any>,
34
22
  T3 extends PipelineTransform<T2, any>,
35
- B extends PipelineDestination<T3, any>>(
36
- source: A,
37
- transform1: T1,
38
- transform2: T2,
39
- transform3: T3,
40
- destination: B,
41
- options?: PipelineOptions
42
- ): PipelinePromise<B>;
43
- function pipeline<A extends PipelineSource<any>,
23
+ B extends PipelineDestination<T3, any>
24
+ >(source: A, transform1: T1, transform2: T2, transform3: T3, destination: B, options?: PipelineOptions): PipelinePromise<B>;
25
+ function pipeline<
26
+ A extends PipelineSource<any>,
44
27
  T1 extends PipelineTransform<A, any>,
45
28
  T2 extends PipelineTransform<T1, any>,
46
29
  T3 extends PipelineTransform<T2, any>,
47
30
  T4 extends PipelineTransform<T3, any>,
48
- B extends PipelineDestination<T4, any>>(
49
- source: A,
50
- transform1: T1,
51
- transform2: T2,
52
- transform3: T3,
53
- transform4: T4,
54
- destination: B,
55
- options?: PipelineOptions
56
- ): PipelinePromise<B>;
57
-
58
- function pipeline(
59
- streams: ReadonlyArray<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>,
60
- options?: PipelineOptions
61
- ): Promise<void>;
31
+ B extends PipelineDestination<T4, any>
32
+ >(source: A, transform1: T1, transform2: T2, transform3: T3, transform4: T4, destination: B, options?: PipelineOptions): PipelinePromise<B>;
33
+ function pipeline(streams: ReadonlyArray<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>, options?: PipelineOptions): Promise<void>;
62
34
  function pipeline(
63
35
  stream1: NodeJS.ReadableStream,
64
36
  stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
65
- ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | PipelineOptions>,
37
+ ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | PipelineOptions>
66
38
  ): Promise<void>;
67
39
  }
68
-
69
40
  declare module 'node:stream/promises' {
70
41
  export * from 'stream/promises';
71
42
  }