@node-red/editor-client 3.0.2 → 3.1.0-beta.2

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.
Files changed (127) hide show
  1. package/locales/de/editor.json +2 -0
  2. package/locales/de/infotips.json +0 -0
  3. package/locales/de/jsonata.json +0 -0
  4. package/locales/en-US/editor.json +37 -6
  5. package/locales/en-US/infotips.json +0 -0
  6. package/locales/en-US/jsonata.json +0 -0
  7. package/locales/fr/editor.json +1238 -0
  8. package/locales/fr/infotips.json +23 -0
  9. package/locales/fr/jsonata.json +274 -0
  10. package/locales/ja/editor.json +48 -9
  11. package/locales/ko/editor.json +233 -31
  12. package/locales/ko/infotips.json +0 -0
  13. package/locales/ko/jsonata.json +0 -0
  14. package/locales/pt-BR/editor.json +1208 -0
  15. package/locales/pt-BR/infotips.json +23 -0
  16. package/locales/pt-BR/jsonata.json +274 -0
  17. package/locales/ru/editor.json +2 -0
  18. package/locales/ru/infotips.json +0 -0
  19. package/locales/ru/jsonata.json +0 -0
  20. package/locales/zh-CN/editor.json +1175 -1049
  21. package/locales/zh-TW/editor.json +3 -0
  22. package/package.json +1 -1
  23. package/public/red/about +140 -0
  24. package/public/red/red.js +2699 -1397
  25. package/public/red/red.min.js +4 -3
  26. package/public/red/style.min.css +1 -1
  27. package/public/red/tours/3.0/images/context-menu.png +0 -0
  28. package/public/red/tours/3.0/welcome.js +155 -0
  29. package/public/red/tours/images/context-menu.png +0 -0
  30. package/public/red/tours/images/global-env-vars.png +0 -0
  31. package/public/red/tours/images/hiding-flows.png +0 -0
  32. package/public/red/tours/images/locking-flows.png +0 -0
  33. package/public/red/tours/images/mermaid.png +0 -0
  34. package/public/red/tours/images/node-help.png +0 -0
  35. package/public/red/tours/images/tab-changes.png +0 -0
  36. package/public/red/tours/welcome.js +111 -94
  37. package/public/types/node/assert/strict.d.ts +11 -0
  38. package/public/types/node/assert.d.ts +898 -64
  39. package/public/types/node/async_hooks.d.ts +362 -94
  40. package/public/types/node/buffer.d.ts +2158 -14
  41. package/public/types/node/child_process.d.ts +1109 -257
  42. package/public/types/node/cluster.d.ts +349 -200
  43. package/public/types/node/console.d.ts +313 -43
  44. package/public/types/node/crypto.d.ts +3329 -656
  45. package/public/types/node/dgram.d.ts +459 -58
  46. package/public/types/node/diagnostics_channel.d.ts +155 -0
  47. package/public/types/node/dns/promises.d.ts +371 -0
  48. package/public/types/node/dns.d.ts +532 -265
  49. package/public/types/node/domain.d.ts +159 -16
  50. package/public/types/node/events.d.ts +589 -30
  51. package/public/types/node/fs/promises.d.ts +1097 -0
  52. package/public/types/node/fs.d.ts +2484 -958
  53. package/public/types/node/globals.d.ts +43 -503
  54. package/public/types/node/http.d.ts +1156 -145
  55. package/public/types/node/http2.d.ts +1610 -470
  56. package/public/types/node/https.d.ts +462 -72
  57. package/public/types/node/module.d.ts +72 -13
  58. package/public/types/node/net.d.ts +663 -131
  59. package/public/types/node/os.d.ts +238 -25
  60. package/public/types/node/path.d.ts +57 -23
  61. package/public/types/node/perf_hooks.d.ts +424 -112
  62. package/public/types/node/process.d.ts +1261 -193
  63. package/public/types/node/querystring.d.ts +107 -7
  64. package/public/types/node/readline.d.ts +443 -74
  65. package/public/types/node/stream/consumers.d.ts +15 -0
  66. package/public/types/node/stream/promises.d.ts +45 -0
  67. package/public/types/node/stream/web.d.ts +395 -0
  68. package/public/types/node/stream.d.ts +1081 -177
  69. package/public/types/node/string_decoder.d.ts +57 -0
  70. package/public/types/node/test.d.ts +193 -0
  71. package/public/types/node/timers/promises.d.ts +96 -0
  72. package/public/types/node/timers.d.ts +87 -12
  73. package/public/types/node/tls.d.ts +457 -222
  74. package/public/types/node/trace_events.d.ts +107 -10
  75. package/public/types/node/tty.d.ts +158 -23
  76. package/public/types/node/url.d.ts +734 -28
  77. package/public/types/node/util.d.ts +1542 -164
  78. package/public/types/node/v8.d.ts +261 -73
  79. package/public/types/node/vm.d.ts +384 -32
  80. package/public/types/node/wasi.d.ts +92 -23
  81. package/public/types/node/worker_threads.d.ts +531 -123
  82. package/public/types/node/zlib.d.ts +216 -63
  83. package/public/types/node-red/func.d.ts +3 -0
  84. package/public/vendor/jquery/css/base/images/ui-icons_444444_256x240.png +0 -0
  85. package/public/vendor/jquery/css/base/images/ui-icons_555555_256x240.png +0 -0
  86. package/public/vendor/jquery/css/base/images/ui-icons_777620_256x240.png +0 -0
  87. package/public/vendor/jquery/css/base/images/ui-icons_777777_256x240.png +0 -0
  88. package/public/vendor/jquery/css/base/images/ui-icons_cc0000_256x240.png +0 -0
  89. package/public/vendor/jquery/css/base/images/ui-icons_ffffff_256x240.png +0 -0
  90. package/public/vendor/jquery/css/base/jquery-ui.min.css +4 -4
  91. package/public/vendor/mermaid/mermaid.min.js +1284 -0
  92. package/public/vendor/monaco/dist/{ade705761eb7e702770d.ttf → 7064e66c3890a12c47b4.ttf} +0 -0
  93. package/public/vendor/monaco/dist/css.worker.js +1 -1
  94. package/public/vendor/monaco/dist/css.worker.js.LICENSE.txt +1 -1
  95. package/public/vendor/monaco/dist/editor.js +1 -1
  96. package/public/vendor/monaco/dist/editor.js.LICENSE.txt +5 -1
  97. package/public/vendor/monaco/dist/editor.worker.js +1 -1
  98. package/public/vendor/monaco/dist/html.worker.js +1 -1
  99. package/public/vendor/monaco/dist/html.worker.js.LICENSE.txt +1 -1
  100. package/public/vendor/monaco/dist/json.worker.js +1 -1
  101. package/public/vendor/monaco/dist/json.worker.js.LICENSE.txt +1 -1
  102. package/public/vendor/monaco/dist/locale/cs.js +319 -71
  103. package/public/vendor/monaco/dist/locale/de.js +323 -75
  104. package/public/vendor/monaco/dist/locale/es.js +318 -70
  105. package/public/vendor/monaco/dist/locale/fr.js +327 -79
  106. package/public/vendor/monaco/dist/locale/it.js +325 -77
  107. package/public/vendor/monaco/dist/locale/ja.js +337 -89
  108. package/public/vendor/monaco/dist/locale/ko.js +324 -76
  109. package/public/vendor/monaco/dist/locale/pl.js +322 -74
  110. package/public/vendor/monaco/dist/locale/pt-br.js +321 -73
  111. package/public/vendor/monaco/dist/locale/qps-ploc.js +1580 -1332
  112. package/public/vendor/monaco/dist/locale/ru.js +324 -76
  113. package/public/vendor/monaco/dist/locale/tr.js +326 -78
  114. package/public/vendor/monaco/dist/locale/zh-hans.js +328 -80
  115. package/public/vendor/monaco/dist/locale/zh-hant.js +321 -73
  116. package/public/vendor/monaco/dist/theme/forge.json +236 -0
  117. package/public/vendor/monaco/dist/theme/github-dark.json +348 -0
  118. package/public/vendor/monaco/dist/theme/github-light.json +348 -0
  119. package/public/vendor/monaco/dist/theme/nord.json +93 -0
  120. package/public/vendor/monaco/dist/ts.worker.js +1 -1
  121. package/public/vendor/monaco/dist/ts.worker.js.LICENSE.txt +14 -6
  122. package/public/vendor/vendor.js +9 -15
  123. /package/public/red/tours/{images → 3.0/images}/continuous-search.png +0 -0
  124. /package/public/red/tours/{images → 3.0/images}/debug-path-tooltip.png +0 -0
  125. /package/public/red/tours/{images → 3.0/images}/junction-quick-add.png +0 -0
  126. /package/public/red/tours/{images → 3.0/images}/junction-slice.gif +0 -0
  127. /package/public/red/tours/{images → 3.0/images}/split-wire-with-links.gif +0 -0
@@ -1,55 +1,418 @@
1
1
 
2
2
  /* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
3
3
 
4
+ /**
5
+ * A stream is an abstract interface for working with streaming data in Node.js.
6
+ * The `stream` module provides an API for implementing the stream interface.
7
+ *
8
+ * There are many stream objects provided by Node.js. For instance, a `request to an HTTP server` and `process.stdout` are both stream instances.
9
+ *
10
+ * Streams can be readable, writable, or both. All streams are instances of `EventEmitter`.
11
+ *
12
+ * To access the `stream` module:
13
+ *
14
+ * ```js
15
+ * const stream = require('stream');
16
+ * ```
17
+ *
18
+ * The `stream` module is useful for creating new types of stream instances. It is
19
+ * usually not necessary to use the `stream` module to consume streams.
20
+ * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/stream.js)
21
+ */
4
22
  declare module 'stream' {
5
- import EventEmitter = require('events');
6
-
23
+ import { EventEmitter, Abortable } from 'node:events';
24
+ import { Blob as NodeBlob } from 'node:buffer';
25
+ import * as streamPromises from 'node:stream/promises';
26
+ import * as streamConsumers from 'node:stream/consumers';
7
27
  class internal extends EventEmitter {
8
- pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean | undefined; }): T;
28
+ pipe<T extends NodeJS.WritableStream>(
29
+ destination: T,
30
+ options?: {
31
+ end?: boolean | undefined;
32
+ }
33
+ ): T;
9
34
  }
10
-
11
35
  namespace internal {
12
36
  class Stream extends internal {
13
37
  constructor(opts?: ReadableOptions);
14
38
  }
15
-
16
- interface ReadableOptions {
39
+ interface StreamOptions<T extends Stream> extends Abortable {
40
+ emitClose?: boolean | undefined;
17
41
  highWaterMark?: number | undefined;
18
- encoding?: BufferEncoding | undefined;
19
42
  objectMode?: boolean | undefined;
20
- read?(this: Readable, size: number): void;
21
- destroy?(this: Readable, error: Error | null, callback: (error: Error | null) => void): void;
43
+ construct?(this: T, callback: (error?: Error | null) => void): void;
44
+ destroy?(this: T, error: Error | null, callback: (error: Error | null) => void): void;
22
45
  autoDestroy?: boolean | undefined;
23
46
  }
24
-
47
+ interface ReadableOptions extends StreamOptions<Readable> {
48
+ encoding?: BufferEncoding | undefined;
49
+ read?(this: Readable, size: number): void;
50
+ }
51
+ /**
52
+ * @since v0.9.4
53
+ */
25
54
  class Readable extends Stream implements NodeJS.ReadableStream {
26
55
  /**
27
56
  * A utility method for creating Readable Streams out of iterators.
28
57
  */
29
58
  static from(iterable: Iterable<any> | AsyncIterable<any>, options?: ReadableOptions): Readable;
30
-
59
+ /**
60
+ * Returns whether the stream has been read from or cancelled.
61
+ * @since v16.8.0
62
+ */
63
+ static isDisturbed(stream: Readable | NodeJS.ReadableStream): boolean;
64
+ /**
65
+ * Returns whether the stream was destroyed or errored before emitting `'end'`.
66
+ * @since v16.8.0
67
+ * @experimental
68
+ */
69
+ readonly readableAborted: boolean;
70
+ /**
71
+ * Is `true` if it is safe to call `readable.read()`, which means
72
+ * the stream has not been destroyed or emitted `'error'` or `'end'`.
73
+ * @since v11.4.0
74
+ */
31
75
  readable: boolean;
76
+ /**
77
+ * Returns whether `'data'` has been emitted.
78
+ * @since v16.7.0
79
+ * @experimental
80
+ */
81
+ readonly readableDidRead: boolean;
82
+ /**
83
+ * Getter for the property `encoding` of a given `Readable` stream. The `encoding`property can be set using the `readable.setEncoding()` method.
84
+ * @since v12.7.0
85
+ */
32
86
  readonly readableEncoding: BufferEncoding | null;
87
+ /**
88
+ * Becomes `true` when `'end'` event is emitted.
89
+ * @since v12.9.0
90
+ */
33
91
  readonly readableEnded: boolean;
92
+ /**
93
+ * This property reflects the current state of a `Readable` stream as described
94
+ * in the `Three states` section.
95
+ * @since v9.4.0
96
+ */
34
97
  readonly readableFlowing: boolean | null;
98
+ /**
99
+ * Returns the value of `highWaterMark` passed when creating this `Readable`.
100
+ * @since v9.3.0
101
+ */
35
102
  readonly readableHighWaterMark: number;
103
+ /**
104
+ * This property contains the number of bytes (or objects) in the queue
105
+ * ready to be read. The value provides introspection data regarding
106
+ * the status of the `highWaterMark`.
107
+ * @since v9.4.0
108
+ */
36
109
  readonly readableLength: number;
110
+ /**
111
+ * Getter for the property `objectMode` of a given `Readable` stream.
112
+ * @since v12.3.0
113
+ */
37
114
  readonly readableObjectMode: boolean;
115
+ /**
116
+ * Is `true` after `readable.destroy()` has been called.
117
+ * @since v8.0.0
118
+ */
38
119
  destroyed: boolean;
39
120
  constructor(opts?: ReadableOptions);
121
+ _construct?(callback: (error?: Error | null) => void): void;
40
122
  _read(size: number): void;
123
+ /**
124
+ * The `readable.read()` method pulls some data out of the internal buffer and
125
+ * returns it. If no data available to be read, `null` is returned. By default,
126
+ * the data will be returned as a `Buffer` object unless an encoding has been
127
+ * specified using the `readable.setEncoding()` method or the stream is operating
128
+ * in object mode.
129
+ *
130
+ * The optional `size` argument specifies a specific number of bytes to read. If`size` bytes are not available to be read, `null` will be returned _unless_the stream has ended, in which
131
+ * case all of the data remaining in the internal
132
+ * buffer will be returned.
133
+ *
134
+ * If the `size` argument is not specified, all of the data contained in the
135
+ * internal buffer will be returned.
136
+ *
137
+ * The `size` argument must be less than or equal to 1 GiB.
138
+ *
139
+ * The `readable.read()` method should only be called on `Readable` streams
140
+ * operating in paused mode. In flowing mode, `readable.read()` is called
141
+ * automatically until the internal buffer is fully drained.
142
+ *
143
+ * ```js
144
+ * const readable = getReadableStreamSomehow();
145
+ *
146
+ * // 'readable' may be triggered multiple times as data is buffered in
147
+ * readable.on('readable', () => {
148
+ * let chunk;
149
+ * console.log('Stream is readable (new data received in buffer)');
150
+ * // Use a loop to make sure we read all currently available data
151
+ * while (null !== (chunk = readable.read())) {
152
+ * console.log(`Read ${chunk.length} bytes of data...`);
153
+ * }
154
+ * });
155
+ *
156
+ * // 'end' will be triggered once when there is no more data available
157
+ * readable.on('end', () => {
158
+ * console.log('Reached end of stream.');
159
+ * });
160
+ * ```
161
+ *
162
+ * Each call to `readable.read()` returns a chunk of data, or `null`. The chunks
163
+ * are not concatenated. A `while` loop is necessary to consume all data
164
+ * currently in the buffer. When reading a large file `.read()` may return `null`,
165
+ * having consumed all buffered content so far, but there is still more data to
166
+ * come not yet buffered. In this case a new `'readable'` event will be emitted
167
+ * when there is more data in the buffer. Finally the `'end'` event will be
168
+ * emitted when there is no more data to come.
169
+ *
170
+ * Therefore to read a file's whole contents from a `readable`, it is necessary
171
+ * to collect chunks across multiple `'readable'` events:
172
+ *
173
+ * ```js
174
+ * const chunks = [];
175
+ *
176
+ * readable.on('readable', () => {
177
+ * let chunk;
178
+ * while (null !== (chunk = readable.read())) {
179
+ * chunks.push(chunk);
180
+ * }
181
+ * });
182
+ *
183
+ * readable.on('end', () => {
184
+ * const content = chunks.join('');
185
+ * });
186
+ * ```
187
+ *
188
+ * A `Readable` stream in object mode will always return a single item from
189
+ * a call to `readable.read(size)`, regardless of the value of the`size` argument.
190
+ *
191
+ * If the `readable.read()` method returns a chunk of data, a `'data'` event will
192
+ * also be emitted.
193
+ *
194
+ * Calling {@link read} after the `'end'` event has
195
+ * been emitted will return `null`. No runtime error will be raised.
196
+ * @since v0.9.4
197
+ * @param size Optional argument to specify how much data to read.
198
+ */
41
199
  read(size?: number): any;
200
+ /**
201
+ * The `readable.setEncoding()` method sets the character encoding for
202
+ * data read from the `Readable` stream.
203
+ *
204
+ * By default, no encoding is assigned and stream data will be returned as`Buffer` objects. Setting an encoding causes the stream data
205
+ * to be returned as strings of the specified encoding rather than as `Buffer`objects. For instance, calling `readable.setEncoding('utf8')` will cause the
206
+ * output data to be interpreted as UTF-8 data, and passed as strings. Calling`readable.setEncoding('hex')` will cause the data to be encoded in hexadecimal
207
+ * string format.
208
+ *
209
+ * The `Readable` stream will properly handle multi-byte characters delivered
210
+ * through the stream that would otherwise become improperly decoded if simply
211
+ * pulled from the stream as `Buffer` objects.
212
+ *
213
+ * ```js
214
+ * const readable = getReadableStreamSomehow();
215
+ * readable.setEncoding('utf8');
216
+ * readable.on('data', (chunk) => {
217
+ * assert.equal(typeof chunk, 'string');
218
+ * console.log('Got %d characters of string data:', chunk.length);
219
+ * });
220
+ * ```
221
+ * @since v0.9.4
222
+ * @param encoding The encoding to use.
223
+ */
42
224
  setEncoding(encoding: BufferEncoding): this;
225
+ /**
226
+ * The `readable.pause()` method will cause a stream in flowing mode to stop
227
+ * emitting `'data'` events, switching out of flowing mode. Any data that
228
+ * becomes available will remain in the internal buffer.
229
+ *
230
+ * ```js
231
+ * const readable = getReadableStreamSomehow();
232
+ * readable.on('data', (chunk) => {
233
+ * console.log(`Received ${chunk.length} bytes of data.`);
234
+ * readable.pause();
235
+ * console.log('There will be no additional data for 1 second.');
236
+ * setTimeout(() => {
237
+ * console.log('Now data will start flowing again.');
238
+ * readable.resume();
239
+ * }, 1000);
240
+ * });
241
+ * ```
242
+ *
243
+ * The `readable.pause()` method has no effect if there is a `'readable'`event listener.
244
+ * @since v0.9.4
245
+ */
43
246
  pause(): this;
247
+ /**
248
+ * The `readable.resume()` method causes an explicitly paused `Readable` stream to
249
+ * resume emitting `'data'` events, switching the stream into flowing mode.
250
+ *
251
+ * The `readable.resume()` method can be used to fully consume the data from a
252
+ * stream without actually processing any of that data:
253
+ *
254
+ * ```js
255
+ * getReadableStreamSomehow()
256
+ * .resume()
257
+ * .on('end', () => {
258
+ * console.log('Reached the end, but did not read anything.');
259
+ * });
260
+ * ```
261
+ *
262
+ * The `readable.resume()` method has no effect if there is a `'readable'`event listener.
263
+ * @since v0.9.4
264
+ */
44
265
  resume(): this;
266
+ /**
267
+ * The `readable.isPaused()` method returns the current operating state of the`Readable`. This is used primarily by the mechanism that underlies the`readable.pipe()` method. In most
268
+ * typical cases, there will be no reason to
269
+ * use this method directly.
270
+ *
271
+ * ```js
272
+ * const readable = new stream.Readable();
273
+ *
274
+ * readable.isPaused(); // === false
275
+ * readable.pause();
276
+ * readable.isPaused(); // === true
277
+ * readable.resume();
278
+ * readable.isPaused(); // === false
279
+ * ```
280
+ * @since v0.11.14
281
+ */
45
282
  isPaused(): boolean;
283
+ /**
284
+ * The `readable.unpipe()` method detaches a `Writable` stream previously attached
285
+ * using the {@link pipe} method.
286
+ *
287
+ * If the `destination` is not specified, then _all_ pipes are detached.
288
+ *
289
+ * If the `destination` is specified, but no pipe is set up for it, then
290
+ * the method does nothing.
291
+ *
292
+ * ```js
293
+ * const fs = require('fs');
294
+ * const readable = getReadableStreamSomehow();
295
+ * const writable = fs.createWriteStream('file.txt');
296
+ * // All the data from readable goes into 'file.txt',
297
+ * // but only for the first second.
298
+ * readable.pipe(writable);
299
+ * setTimeout(() => {
300
+ * console.log('Stop writing to file.txt.');
301
+ * readable.unpipe(writable);
302
+ * console.log('Manually close the file stream.');
303
+ * writable.end();
304
+ * }, 1000);
305
+ * ```
306
+ * @since v0.9.4
307
+ * @param destination Optional specific stream to unpipe
308
+ */
46
309
  unpipe(destination?: NodeJS.WritableStream): this;
310
+ /**
311
+ * Passing `chunk` as `null` signals the end of the stream (EOF) and behaves the
312
+ * same as `readable.push(null)`, after which no more data can be written. The EOF
313
+ * signal is put at the end of the buffer and any buffered data will still be
314
+ * flushed.
315
+ *
316
+ * The `readable.unshift()` method pushes a chunk of data back into the internal
317
+ * buffer. This is useful in certain situations where a stream is being consumed by
318
+ * code that needs to "un-consume" some amount of data that it has optimistically
319
+ * pulled out of the source, so that the data can be passed on to some other party.
320
+ *
321
+ * The `stream.unshift(chunk)` method cannot be called after the `'end'` event
322
+ * has been emitted or a runtime error will be thrown.
323
+ *
324
+ * Developers using `stream.unshift()` often should consider switching to
325
+ * use of a `Transform` stream instead. See the `API for stream implementers` section for more information.
326
+ *
327
+ * ```js
328
+ * // Pull off a header delimited by \n\n.
329
+ * // Use unshift() if we get too much.
330
+ * // Call the callback with (error, header, stream).
331
+ * const { StringDecoder } = require('string_decoder');
332
+ * function parseHeader(stream, callback) {
333
+ * stream.on('error', callback);
334
+ * stream.on('readable', onReadable);
335
+ * const decoder = new StringDecoder('utf8');
336
+ * let header = '';
337
+ * function onReadable() {
338
+ * let chunk;
339
+ * while (null !== (chunk = stream.read())) {
340
+ * const str = decoder.write(chunk);
341
+ * if (str.match(/\n\n/)) {
342
+ * // Found the header boundary.
343
+ * const split = str.split(/\n\n/);
344
+ * header += split.shift();
345
+ * const remaining = split.join('\n\n');
346
+ * const buf = Buffer.from(remaining, 'utf8');
347
+ * stream.removeListener('error', callback);
348
+ * // Remove the 'readable' listener before unshifting.
349
+ * stream.removeListener('readable', onReadable);
350
+ * if (buf.length)
351
+ * stream.unshift(buf);
352
+ * // Now the body of the message can be read from the stream.
353
+ * callback(null, header, stream);
354
+ * } else {
355
+ * // Still reading the header.
356
+ * header += str;
357
+ * }
358
+ * }
359
+ * }
360
+ * }
361
+ * ```
362
+ *
363
+ * Unlike {@link push}, `stream.unshift(chunk)` will not
364
+ * end the reading process by resetting the internal reading state of the stream.
365
+ * This can cause unexpected results if `readable.unshift()` is called during a
366
+ * read (i.e. from within a {@link _read} implementation on a
367
+ * custom stream). Following the call to `readable.unshift()` with an immediate {@link push} will reset the reading state appropriately,
368
+ * however it is best to simply avoid calling `readable.unshift()` while in the
369
+ * process of performing a read.
370
+ * @since v0.9.11
371
+ * @param chunk Chunk of data to unshift onto the read queue. For streams not operating in object mode, `chunk` must be a string, `Buffer`, `Uint8Array` or `null`. For object mode
372
+ * streams, `chunk` may be any JavaScript value.
373
+ * @param encoding Encoding of string chunks. Must be a valid `Buffer` encoding, such as `'utf8'` or `'ascii'`.
374
+ */
47
375
  unshift(chunk: any, encoding?: BufferEncoding): void;
48
- wrap(oldStream: NodeJS.ReadableStream): this;
376
+ /**
377
+ * Prior to Node.js 0.10, streams did not implement the entire `stream` module API
378
+ * as it is currently defined. (See `Compatibility` for more information.)
379
+ *
380
+ * When using an older Node.js library that emits `'data'` events and has a {@link pause} method that is advisory only, the`readable.wrap()` method can be used to create a `Readable`
381
+ * stream that uses
382
+ * the old stream as its data source.
383
+ *
384
+ * It will rarely be necessary to use `readable.wrap()` but the method has been
385
+ * provided as a convenience for interacting with older Node.js applications and
386
+ * libraries.
387
+ *
388
+ * ```js
389
+ * const { OldReader } = require('./old-api-module.js');
390
+ * const { Readable } = require('stream');
391
+ * const oreader = new OldReader();
392
+ * const myReader = new Readable().wrap(oreader);
393
+ *
394
+ * myReader.on('readable', () => {
395
+ * myReader.read(); // etc.
396
+ * });
397
+ * ```
398
+ * @since v0.9.4
399
+ * @param stream An "old style" readable stream
400
+ */
401
+ wrap(stream: NodeJS.ReadableStream): this;
49
402
  push(chunk: any, encoding?: BufferEncoding): boolean;
50
403
  _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
404
+ /**
405
+ * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the readable
406
+ * stream will release any internal resources and subsequent calls to `push()`will be ignored.
407
+ *
408
+ * Once `destroy()` has been called any further calls will be a no-op and no
409
+ * further errors except from `_destroy()` may be emitted as `'error'`.
410
+ *
411
+ * Implementors should not override this method, but instead implement `readable._destroy()`.
412
+ * @since v8.0.0
413
+ * @param error Error which will be passed as payload in `'error'` event
414
+ */
51
415
  destroy(error?: Error): this;
52
-
53
416
  /**
54
417
  * Event emitter
55
418
  * The defined events on documents including:
@@ -61,109 +424,294 @@ declare module 'stream' {
61
424
  * 6. readable
62
425
  * 7. resume
63
426
  */
64
- addListener(event: "close", listener: () => void): this;
65
- addListener(event: "data", listener: (chunk: any) => void): this;
66
- addListener(event: "end", listener: () => void): this;
67
- addListener(event: "error", listener: (err: Error) => void): this;
68
- addListener(event: "pause", listener: () => void): this;
69
- addListener(event: "readable", listener: () => void): this;
70
- addListener(event: "resume", listener: () => void): this;
427
+ addListener(event: 'close', listener: () => void): this;
428
+ addListener(event: 'data', listener: (chunk: any) => void): this;
429
+ addListener(event: 'end', listener: () => void): this;
430
+ addListener(event: 'error', listener: (err: Error) => void): this;
431
+ addListener(event: 'pause', listener: () => void): this;
432
+ addListener(event: 'readable', listener: () => void): this;
433
+ addListener(event: 'resume', listener: () => void): this;
71
434
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
72
-
73
- emit(event: "close"): boolean;
74
- emit(event: "data", chunk: any): boolean;
75
- emit(event: "end"): boolean;
76
- emit(event: "error", err: Error): boolean;
77
- emit(event: "pause"): boolean;
78
- emit(event: "readable"): boolean;
79
- emit(event: "resume"): boolean;
435
+ emit(event: 'close'): boolean;
436
+ emit(event: 'data', chunk: any): boolean;
437
+ emit(event: 'end'): boolean;
438
+ emit(event: 'error', err: Error): boolean;
439
+ emit(event: 'pause'): boolean;
440
+ emit(event: 'readable'): boolean;
441
+ emit(event: 'resume'): boolean;
80
442
  emit(event: string | symbol, ...args: any[]): boolean;
81
-
82
- on(event: "close", listener: () => void): this;
83
- on(event: "data", listener: (chunk: any) => void): this;
84
- on(event: "end", listener: () => void): this;
85
- on(event: "error", listener: (err: Error) => void): this;
86
- on(event: "pause", listener: () => void): this;
87
- on(event: "readable", listener: () => void): this;
88
- on(event: "resume", listener: () => void): this;
443
+ on(event: 'close', listener: () => void): this;
444
+ on(event: 'data', listener: (chunk: any) => void): this;
445
+ on(event: 'end', listener: () => void): this;
446
+ on(event: 'error', listener: (err: Error) => void): this;
447
+ on(event: 'pause', listener: () => void): this;
448
+ on(event: 'readable', listener: () => void): this;
449
+ on(event: 'resume', listener: () => void): this;
89
450
  on(event: string | symbol, listener: (...args: any[]) => void): this;
90
-
91
- once(event: "close", listener: () => void): this;
92
- once(event: "data", listener: (chunk: any) => void): this;
93
- once(event: "end", listener: () => void): this;
94
- once(event: "error", listener: (err: Error) => void): this;
95
- once(event: "pause", listener: () => void): this;
96
- once(event: "readable", listener: () => void): this;
97
- once(event: "resume", listener: () => void): this;
451
+ once(event: 'close', listener: () => void): this;
452
+ once(event: 'data', listener: (chunk: any) => void): this;
453
+ once(event: 'end', listener: () => void): this;
454
+ once(event: 'error', listener: (err: Error) => void): this;
455
+ once(event: 'pause', listener: () => void): this;
456
+ once(event: 'readable', listener: () => void): this;
457
+ once(event: 'resume', listener: () => void): this;
98
458
  once(event: string | symbol, listener: (...args: any[]) => void): this;
99
-
100
- prependListener(event: "close", listener: () => void): this;
101
- prependListener(event: "data", listener: (chunk: any) => void): this;
102
- prependListener(event: "end", listener: () => void): this;
103
- prependListener(event: "error", listener: (err: Error) => void): this;
104
- prependListener(event: "pause", listener: () => void): this;
105
- prependListener(event: "readable", listener: () => void): this;
106
- prependListener(event: "resume", listener: () => void): this;
459
+ prependListener(event: 'close', listener: () => void): this;
460
+ prependListener(event: 'data', listener: (chunk: any) => void): this;
461
+ prependListener(event: 'end', listener: () => void): this;
462
+ prependListener(event: 'error', listener: (err: Error) => void): this;
463
+ prependListener(event: 'pause', listener: () => void): this;
464
+ prependListener(event: 'readable', listener: () => void): this;
465
+ prependListener(event: 'resume', listener: () => void): this;
107
466
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
108
-
109
- prependOnceListener(event: "close", listener: () => void): this;
110
- prependOnceListener(event: "data", listener: (chunk: any) => void): this;
111
- prependOnceListener(event: "end", listener: () => void): this;
112
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
113
- prependOnceListener(event: "pause", listener: () => void): this;
114
- prependOnceListener(event: "readable", listener: () => void): this;
115
- prependOnceListener(event: "resume", listener: () => void): this;
467
+ prependOnceListener(event: 'close', listener: () => void): this;
468
+ prependOnceListener(event: 'data', listener: (chunk: any) => void): this;
469
+ prependOnceListener(event: 'end', listener: () => void): this;
470
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
471
+ prependOnceListener(event: 'pause', listener: () => void): this;
472
+ prependOnceListener(event: 'readable', listener: () => void): this;
473
+ prependOnceListener(event: 'resume', listener: () => void): this;
116
474
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
117
-
118
- removeListener(event: "close", listener: () => void): this;
119
- removeListener(event: "data", listener: (chunk: any) => void): this;
120
- removeListener(event: "end", listener: () => void): this;
121
- removeListener(event: "error", listener: (err: Error) => void): this;
122
- removeListener(event: "pause", listener: () => void): this;
123
- removeListener(event: "readable", listener: () => void): this;
124
- removeListener(event: "resume", listener: () => void): this;
475
+ removeListener(event: 'close', listener: () => void): this;
476
+ removeListener(event: 'data', listener: (chunk: any) => void): this;
477
+ removeListener(event: 'end', listener: () => void): this;
478
+ removeListener(event: 'error', listener: (err: Error) => void): this;
479
+ removeListener(event: 'pause', listener: () => void): this;
480
+ removeListener(event: 'readable', listener: () => void): this;
481
+ removeListener(event: 'resume', listener: () => void): this;
125
482
  removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
126
-
127
483
  [Symbol.asyncIterator](): AsyncIterableIterator<any>;
128
484
  }
129
-
130
- interface WritableOptions {
131
- highWaterMark?: number | undefined;
485
+ interface WritableOptions extends StreamOptions<Writable> {
132
486
  decodeStrings?: boolean | undefined;
133
487
  defaultEncoding?: BufferEncoding | undefined;
134
- objectMode?: boolean | undefined;
135
- emitClose?: boolean | undefined;
136
488
  write?(this: Writable, chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
137
- writev?(this: Writable, chunks: Array<{ chunk: any, encoding: BufferEncoding }>, callback: (error?: Error | null) => void): void;
138
- destroy?(this: Writable, error: Error | null, callback: (error: Error | null) => void): void;
489
+ writev?(
490
+ this: Writable,
491
+ chunks: Array<{
492
+ chunk: any;
493
+ encoding: BufferEncoding;
494
+ }>,
495
+ callback: (error?: Error | null) => void
496
+ ): void;
139
497
  final?(this: Writable, callback: (error?: Error | null) => void): void;
140
- autoDestroy?: boolean | undefined;
141
498
  }
142
-
499
+ /**
500
+ * @since v0.9.4
501
+ */
143
502
  class Writable extends Stream implements NodeJS.WritableStream {
503
+ /**
504
+ * Is `true` if it is safe to call `writable.write()`, which means
505
+ * the stream has not been destroyed, errored or ended.
506
+ * @since v11.4.0
507
+ */
144
508
  readonly writable: boolean;
509
+ /**
510
+ * Is `true` after `writable.end()` has been called. This property
511
+ * does not indicate whether the data has been flushed, for this use `writable.writableFinished` instead.
512
+ * @since v12.9.0
513
+ */
145
514
  readonly writableEnded: boolean;
515
+ /**
516
+ * Is set to `true` immediately before the `'finish'` event is emitted.
517
+ * @since v12.6.0
518
+ */
146
519
  readonly writableFinished: boolean;
520
+ /**
521
+ * Return the value of `highWaterMark` passed when creating this `Writable`.
522
+ * @since v9.3.0
523
+ */
147
524
  readonly writableHighWaterMark: number;
525
+ /**
526
+ * This property contains the number of bytes (or objects) in the queue
527
+ * ready to be written. The value provides introspection data regarding
528
+ * the status of the `highWaterMark`.
529
+ * @since v9.4.0
530
+ */
148
531
  readonly writableLength: number;
532
+ /**
533
+ * Getter for the property `objectMode` of a given `Writable` stream.
534
+ * @since v12.3.0
535
+ */
149
536
  readonly writableObjectMode: boolean;
537
+ /**
538
+ * Number of times `writable.uncork()` needs to be
539
+ * called in order to fully uncork the stream.
540
+ * @since v13.2.0, v12.16.0
541
+ */
150
542
  readonly writableCorked: number;
543
+ /**
544
+ * Is `true` after `writable.destroy()` has been called.
545
+ * @since v8.0.0
546
+ */
151
547
  destroyed: boolean;
152
548
  constructor(opts?: WritableOptions);
153
549
  _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
154
- _writev?(chunks: Array<{ chunk: any, encoding: BufferEncoding }>, callback: (error?: Error | null) => void): void;
550
+ _writev?(
551
+ chunks: Array<{
552
+ chunk: any;
553
+ encoding: BufferEncoding;
554
+ }>,
555
+ callback: (error?: Error | null) => void
556
+ ): void;
557
+ _construct?(callback: (error?: Error | null) => void): void;
155
558
  _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
156
559
  _final(callback: (error?: Error | null) => void): void;
157
- write(chunk: any, cb?: (error: Error | null | undefined) => void): boolean;
158
- write(chunk: any, encoding: BufferEncoding, cb?: (error: Error | null | undefined) => void): boolean;
560
+ /**
561
+ * The `writable.write()` method writes some data to the stream, and calls the
562
+ * supplied `callback` once the data has been fully handled. If an error
563
+ * occurs, the `callback` will be called with the error as its
564
+ * first argument. The `callback` is called asynchronously and before `'error'` is
565
+ * emitted.
566
+ *
567
+ * The return value is `true` if the internal buffer is less than the`highWaterMark` configured when the stream was created after admitting `chunk`.
568
+ * If `false` is returned, further attempts to write data to the stream should
569
+ * stop until the `'drain'` event is emitted.
570
+ *
571
+ * While a stream is not draining, calls to `write()` will buffer `chunk`, and
572
+ * return false. Once all currently buffered chunks are drained (accepted for
573
+ * delivery by the operating system), the `'drain'` event will be emitted.
574
+ * It is recommended that once `write()` returns false, no more chunks be written
575
+ * until the `'drain'` event is emitted. While calling `write()` on a stream that
576
+ * is not draining is allowed, Node.js will buffer all written chunks until
577
+ * maximum memory usage occurs, at which point it will abort unconditionally.
578
+ * Even before it aborts, high memory usage will cause poor garbage collector
579
+ * performance and high RSS (which is not typically released back to the system,
580
+ * even after the memory is no longer required). Since TCP sockets may never
581
+ * drain if the remote peer does not read the data, writing a socket that is
582
+ * not draining may lead to a remotely exploitable vulnerability.
583
+ *
584
+ * Writing data while the stream is not draining is particularly
585
+ * problematic for a `Transform`, because the `Transform` streams are paused
586
+ * by default until they are piped or a `'data'` or `'readable'` event handler
587
+ * is added.
588
+ *
589
+ * If the data to be written can be generated or fetched on demand, it is
590
+ * recommended to encapsulate the logic into a `Readable` and use {@link pipe}. However, if calling `write()` is preferred, it is
591
+ * possible to respect backpressure and avoid memory issues using the `'drain'` event:
592
+ *
593
+ * ```js
594
+ * function write(data, cb) {
595
+ * if (!stream.write(data)) {
596
+ * stream.once('drain', cb);
597
+ * } else {
598
+ * process.nextTick(cb);
599
+ * }
600
+ * }
601
+ *
602
+ * // Wait for cb to be called before doing any other write.
603
+ * write('hello', () => {
604
+ * console.log('Write completed, do more writes now.');
605
+ * });
606
+ * ```
607
+ *
608
+ * A `Writable` stream in object mode will always ignore the `encoding` argument.
609
+ * @since v0.9.4
610
+ * @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any
611
+ * JavaScript value other than `null`.
612
+ * @param [encoding='utf8'] The encoding, if `chunk` is a string.
613
+ * @param callback Callback for when this chunk of data is flushed.
614
+ * @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
615
+ */
616
+ write(chunk: any, callback?: (error: Error | null | undefined) => void): boolean;
617
+ write(chunk: any, encoding: BufferEncoding, callback?: (error: Error | null | undefined) => void): boolean;
618
+ /**
619
+ * The `writable.setDefaultEncoding()` method sets the default `encoding` for a `Writable` stream.
620
+ * @since v0.11.15
621
+ * @param encoding The new default encoding
622
+ */
159
623
  setDefaultEncoding(encoding: BufferEncoding): this;
624
+ /**
625
+ * Calling the `writable.end()` method signals that no more data will be written
626
+ * to the `Writable`. The optional `chunk` and `encoding` arguments allow one
627
+ * final additional chunk of data to be written immediately before closing the
628
+ * stream.
629
+ *
630
+ * Calling the {@link write} method after calling {@link end} will raise an error.
631
+ *
632
+ * ```js
633
+ * // Write 'hello, ' and then end with 'world!'.
634
+ * const fs = require('fs');
635
+ * const file = fs.createWriteStream('example.txt');
636
+ * file.write('hello, ');
637
+ * file.end('world!');
638
+ * // Writing more now is not allowed!
639
+ * ```
640
+ * @since v0.9.4
641
+ * @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any
642
+ * JavaScript value other than `null`.
643
+ * @param encoding The encoding if `chunk` is a string
644
+ * @param callback Callback for when the stream is finished.
645
+ */
160
646
  end(cb?: () => void): this;
161
647
  end(chunk: any, cb?: () => void): this;
162
648
  end(chunk: any, encoding: BufferEncoding, cb?: () => void): this;
649
+ /**
650
+ * The `writable.cork()` method forces all written data to be buffered in memory.
651
+ * The buffered data will be flushed when either the {@link uncork} or {@link end} methods are called.
652
+ *
653
+ * The primary intent of `writable.cork()` is to accommodate a situation in which
654
+ * several small chunks are written to the stream in rapid succession. Instead of
655
+ * immediately forwarding them to the underlying destination, `writable.cork()`buffers all the chunks until `writable.uncork()` is called, which will pass them
656
+ * all to `writable._writev()`, if present. This prevents a head-of-line blocking
657
+ * situation where data is being buffered while waiting for the first small chunk
658
+ * to be processed. However, use of `writable.cork()` without implementing`writable._writev()` may have an adverse effect on throughput.
659
+ *
660
+ * See also: `writable.uncork()`, `writable._writev()`.
661
+ * @since v0.11.2
662
+ */
163
663
  cork(): void;
664
+ /**
665
+ * The `writable.uncork()` method flushes all data buffered since {@link cork} was called.
666
+ *
667
+ * When using `writable.cork()` and `writable.uncork()` to manage the buffering
668
+ * of writes to a stream, it is recommended that calls to `writable.uncork()` be
669
+ * deferred using `process.nextTick()`. Doing so allows batching of all`writable.write()` calls that occur within a given Node.js event loop phase.
670
+ *
671
+ * ```js
672
+ * stream.cork();
673
+ * stream.write('some ');
674
+ * stream.write('data ');
675
+ * process.nextTick(() => stream.uncork());
676
+ * ```
677
+ *
678
+ * If the `writable.cork()` method is called multiple times on a stream, the
679
+ * same number of calls to `writable.uncork()` must be called to flush the buffered
680
+ * data.
681
+ *
682
+ * ```js
683
+ * stream.cork();
684
+ * stream.write('some ');
685
+ * stream.cork();
686
+ * stream.write('data ');
687
+ * process.nextTick(() => {
688
+ * stream.uncork();
689
+ * // The data will not be flushed until uncork() is called a second time.
690
+ * stream.uncork();
691
+ * });
692
+ * ```
693
+ *
694
+ * See also: `writable.cork()`.
695
+ * @since v0.11.2
696
+ */
164
697
  uncork(): void;
698
+ /**
699
+ * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the writable
700
+ * stream has ended and subsequent calls to `write()` or `end()` will result in
701
+ * an `ERR_STREAM_DESTROYED` error.
702
+ * This is a destructive and immediate way to destroy a stream. Previous calls to`write()` may not have drained, and may trigger an `ERR_STREAM_DESTROYED` error.
703
+ * Use `end()` instead of destroy if data should flush before close, or wait for
704
+ * the `'drain'` event before destroying the stream.
705
+ *
706
+ * Once `destroy()` has been called any further calls will be a no-op and no
707
+ * further errors except from `_destroy()` may be emitted as `'error'`.
708
+ *
709
+ * Implementors should not override this method,
710
+ * but instead implement `writable._destroy()`.
711
+ * @since v8.0.0
712
+ * @param error Optional, an error to emit with `'error'` event.
713
+ */
165
714
  destroy(error?: Error): this;
166
-
167
715
  /**
168
716
  * Event emitter
169
717
  * The defined events on documents including:
@@ -174,63 +722,56 @@ declare module 'stream' {
174
722
  * 5. pipe
175
723
  * 6. unpipe
176
724
  */
177
- addListener(event: "close", listener: () => void): this;
178
- addListener(event: "drain", listener: () => void): this;
179
- addListener(event: "error", listener: (err: Error) => void): this;
180
- addListener(event: "finish", listener: () => void): this;
181
- addListener(event: "pipe", listener: (src: Readable) => void): this;
182
- addListener(event: "unpipe", listener: (src: Readable) => void): this;
725
+ addListener(event: 'close', listener: () => void): this;
726
+ addListener(event: 'drain', listener: () => void): this;
727
+ addListener(event: 'error', listener: (err: Error) => void): this;
728
+ addListener(event: 'finish', listener: () => void): this;
729
+ addListener(event: 'pipe', listener: (src: Readable) => void): this;
730
+ addListener(event: 'unpipe', listener: (src: Readable) => void): this;
183
731
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
184
-
185
- emit(event: "close"): boolean;
186
- emit(event: "drain"): boolean;
187
- emit(event: "error", err: Error): boolean;
188
- emit(event: "finish"): boolean;
189
- emit(event: "pipe", src: Readable): boolean;
190
- emit(event: "unpipe", src: Readable): boolean;
732
+ emit(event: 'close'): boolean;
733
+ emit(event: 'drain'): boolean;
734
+ emit(event: 'error', err: Error): boolean;
735
+ emit(event: 'finish'): boolean;
736
+ emit(event: 'pipe', src: Readable): boolean;
737
+ emit(event: 'unpipe', src: Readable): boolean;
191
738
  emit(event: string | symbol, ...args: any[]): boolean;
192
-
193
- on(event: "close", listener: () => void): this;
194
- on(event: "drain", listener: () => void): this;
195
- on(event: "error", listener: (err: Error) => void): this;
196
- on(event: "finish", listener: () => void): this;
197
- on(event: "pipe", listener: (src: Readable) => void): this;
198
- on(event: "unpipe", listener: (src: Readable) => void): this;
739
+ on(event: 'close', listener: () => void): this;
740
+ on(event: 'drain', listener: () => void): this;
741
+ on(event: 'error', listener: (err: Error) => void): this;
742
+ on(event: 'finish', listener: () => void): this;
743
+ on(event: 'pipe', listener: (src: Readable) => void): this;
744
+ on(event: 'unpipe', listener: (src: Readable) => void): this;
199
745
  on(event: string | symbol, listener: (...args: any[]) => void): this;
200
-
201
- once(event: "close", listener: () => void): this;
202
- once(event: "drain", listener: () => void): this;
203
- once(event: "error", listener: (err: Error) => void): this;
204
- once(event: "finish", listener: () => void): this;
205
- once(event: "pipe", listener: (src: Readable) => void): this;
206
- once(event: "unpipe", listener: (src: Readable) => void): this;
746
+ once(event: 'close', listener: () => void): this;
747
+ once(event: 'drain', listener: () => void): this;
748
+ once(event: 'error', listener: (err: Error) => void): this;
749
+ once(event: 'finish', listener: () => void): this;
750
+ once(event: 'pipe', listener: (src: Readable) => void): this;
751
+ once(event: 'unpipe', listener: (src: Readable) => void): this;
207
752
  once(event: string | symbol, listener: (...args: any[]) => void): this;
208
-
209
- prependListener(event: "close", listener: () => void): this;
210
- prependListener(event: "drain", listener: () => void): this;
211
- prependListener(event: "error", listener: (err: Error) => void): this;
212
- prependListener(event: "finish", listener: () => void): this;
213
- prependListener(event: "pipe", listener: (src: Readable) => void): this;
214
- prependListener(event: "unpipe", listener: (src: Readable) => void): this;
753
+ prependListener(event: 'close', listener: () => void): this;
754
+ prependListener(event: 'drain', listener: () => void): this;
755
+ prependListener(event: 'error', listener: (err: Error) => void): this;
756
+ prependListener(event: 'finish', listener: () => void): this;
757
+ prependListener(event: 'pipe', listener: (src: Readable) => void): this;
758
+ prependListener(event: 'unpipe', listener: (src: Readable) => void): this;
215
759
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
216
-
217
- prependOnceListener(event: "close", listener: () => void): this;
218
- prependOnceListener(event: "drain", listener: () => void): this;
219
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
220
- prependOnceListener(event: "finish", listener: () => void): this;
221
- prependOnceListener(event: "pipe", listener: (src: Readable) => void): this;
222
- prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this;
760
+ prependOnceListener(event: 'close', listener: () => void): this;
761
+ prependOnceListener(event: 'drain', listener: () => void): this;
762
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
763
+ prependOnceListener(event: 'finish', listener: () => void): this;
764
+ prependOnceListener(event: 'pipe', listener: (src: Readable) => void): this;
765
+ prependOnceListener(event: 'unpipe', listener: (src: Readable) => void): this;
223
766
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
224
-
225
- removeListener(event: "close", listener: () => void): this;
226
- removeListener(event: "drain", listener: () => void): this;
227
- removeListener(event: "error", listener: (err: Error) => void): this;
228
- removeListener(event: "finish", listener: () => void): this;
229
- removeListener(event: "pipe", listener: (src: Readable) => void): this;
230
- removeListener(event: "unpipe", listener: (src: Readable) => void): this;
767
+ removeListener(event: 'close', listener: () => void): this;
768
+ removeListener(event: 'drain', listener: () => void): this;
769
+ removeListener(event: 'error', listener: (err: Error) => void): this;
770
+ removeListener(event: 'finish', listener: () => void): this;
771
+ removeListener(event: 'pipe', listener: (src: Readable) => void): this;
772
+ removeListener(event: 'unpipe', listener: (src: Readable) => void): this;
231
773
  removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
232
774
  }
233
-
234
775
  interface DuplexOptions extends ReadableOptions, WritableOptions {
235
776
  allowHalfOpen?: boolean | undefined;
236
777
  readableObjectMode?: boolean | undefined;
@@ -238,14 +779,30 @@ declare module 'stream' {
238
779
  readableHighWaterMark?: number | undefined;
239
780
  writableHighWaterMark?: number | undefined;
240
781
  writableCorked?: number | undefined;
782
+ construct?(this: Duplex, callback: (error?: Error | null) => void): void;
241
783
  read?(this: Duplex, size: number): void;
242
784
  write?(this: Duplex, chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
243
- writev?(this: Duplex, chunks: Array<{ chunk: any, encoding: BufferEncoding }>, callback: (error?: Error | null) => void): void;
785
+ writev?(
786
+ this: Duplex,
787
+ chunks: Array<{
788
+ chunk: any;
789
+ encoding: BufferEncoding;
790
+ }>,
791
+ callback: (error?: Error | null) => void
792
+ ): void;
244
793
  final?(this: Duplex, callback: (error?: Error | null) => void): void;
245
794
  destroy?(this: Duplex, error: Error | null, callback: (error: Error | null) => void): void;
246
795
  }
247
-
248
- // Note: Duplex extends both Readable and Writable.
796
+ /**
797
+ * Duplex streams are streams that implement both the `Readable` and `Writable` interfaces.
798
+ *
799
+ * Examples of `Duplex` streams include:
800
+ *
801
+ * * `TCP sockets`
802
+ * * `zlib streams`
803
+ * * `crypto streams`
804
+ * @since v0.9.4
805
+ */
249
806
  class Duplex extends Readable implements Writable {
250
807
  readonly writable: boolean;
251
808
  readonly writableEnded: boolean;
@@ -254,10 +811,47 @@ declare module 'stream' {
254
811
  readonly writableLength: number;
255
812
  readonly writableObjectMode: boolean;
256
813
  readonly writableCorked: number;
814
+ /**
815
+ * If `false` then the stream will automatically end the writable side when the
816
+ * readable side ends. Set initially by the `allowHalfOpen` constructor option,
817
+ * which defaults to `false`.
818
+ *
819
+ * This can be changed manually to change the half-open behavior of an existing`Duplex` stream instance, but must be changed before the `'end'` event is
820
+ * emitted.
821
+ * @since v0.9.4
822
+ */
257
823
  allowHalfOpen: boolean;
258
824
  constructor(opts?: DuplexOptions);
825
+ /**
826
+ * A utility method for creating duplex streams.
827
+ *
828
+ * - `Stream` converts writable stream into writable `Duplex` and readable stream
829
+ * to `Duplex`.
830
+ * - `Blob` converts into readable `Duplex`.
831
+ * - `string` converts into readable `Duplex`.
832
+ * - `ArrayBuffer` converts into readable `Duplex`.
833
+ * - `AsyncIterable` converts into a readable `Duplex`. Cannot yield `null`.
834
+ * - `AsyncGeneratorFunction` converts into a readable/writable transform
835
+ * `Duplex`. Must take a source `AsyncIterable` as first parameter. Cannot yield
836
+ * `null`.
837
+ * - `AsyncFunction` converts into a writable `Duplex`. Must return
838
+ * either `null` or `undefined`
839
+ * - `Object ({ writable, readable })` converts `readable` and
840
+ * `writable` into `Stream` and then combines them into `Duplex` where the
841
+ * `Duplex` will write to the `writable` and read from the `readable`.
842
+ * - `Promise` converts into readable `Duplex`. Value `null` is ignored.
843
+ *
844
+ * @since v16.8.0
845
+ */
846
+ static from(src: Stream | NodeBlob | ArrayBuffer | string | Iterable<any> | AsyncIterable<any> | AsyncGeneratorFunction | Promise<any> | Object): Duplex;
259
847
  _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
260
- _writev?(chunks: Array<{ chunk: any, encoding: BufferEncoding }>, callback: (error?: Error | null) => void): void;
848
+ _writev?(
849
+ chunks: Array<{
850
+ chunk: any;
851
+ encoding: BufferEncoding;
852
+ }>,
853
+ callback: (error?: Error | null) => void
854
+ ): void;
261
855
  _destroy(error: Error | null, callback: (error: Error | null) => void): void;
262
856
  _final(callback: (error?: Error | null) => void): void;
263
857
  write(chunk: any, encoding?: BufferEncoding, cb?: (error: Error | null | undefined) => void): boolean;
@@ -269,91 +863,401 @@ declare module 'stream' {
269
863
  cork(): void;
270
864
  uncork(): void;
271
865
  }
272
-
273
866
  type TransformCallback = (error?: Error | null, data?: any) => void;
274
-
275
867
  interface TransformOptions extends DuplexOptions {
868
+ construct?(this: Transform, callback: (error?: Error | null) => void): void;
276
869
  read?(this: Transform, size: number): void;
277
870
  write?(this: Transform, chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
278
- writev?(this: Transform, chunks: Array<{ chunk: any, encoding: BufferEncoding }>, callback: (error?: Error | null) => void): void;
871
+ writev?(
872
+ this: Transform,
873
+ chunks: Array<{
874
+ chunk: any;
875
+ encoding: BufferEncoding;
876
+ }>,
877
+ callback: (error?: Error | null) => void
878
+ ): void;
279
879
  final?(this: Transform, callback: (error?: Error | null) => void): void;
280
880
  destroy?(this: Transform, error: Error | null, callback: (error: Error | null) => void): void;
281
881
  transform?(this: Transform, chunk: any, encoding: BufferEncoding, callback: TransformCallback): void;
282
882
  flush?(this: Transform, callback: TransformCallback): void;
283
883
  }
284
-
884
+ /**
885
+ * Transform streams are `Duplex` streams where the output is in some way
886
+ * related to the input. Like all `Duplex` streams, `Transform` streams
887
+ * implement both the `Readable` and `Writable` interfaces.
888
+ *
889
+ * Examples of `Transform` streams include:
890
+ *
891
+ * * `zlib streams`
892
+ * * `crypto streams`
893
+ * @since v0.9.4
894
+ */
285
895
  class Transform extends Duplex {
286
896
  constructor(opts?: TransformOptions);
287
897
  _transform(chunk: any, encoding: BufferEncoding, callback: TransformCallback): void;
288
898
  _flush(callback: TransformCallback): void;
289
899
  }
290
-
291
- class PassThrough extends Transform { }
292
-
293
- interface FinishedOptions {
900
+ /**
901
+ * The `stream.PassThrough` class is a trivial implementation of a `Transform` stream that simply passes the input bytes across to the output. Its purpose is
902
+ * primarily for examples and testing, but there are some use cases where`stream.PassThrough` is useful as a building block for novel sorts of streams.
903
+ */
904
+ class PassThrough extends Transform {}
905
+ /**
906
+ * Attaches an AbortSignal to a readable or writeable stream. This lets code
907
+ * control stream destruction using an `AbortController`.
908
+ *
909
+ * Calling `abort` on the `AbortController` corresponding to the passed`AbortSignal` will behave the same way as calling `.destroy(new AbortError())`on the stream.
910
+ *
911
+ * ```js
912
+ * const fs = require('fs');
913
+ *
914
+ * const controller = new AbortController();
915
+ * const read = addAbortSignal(
916
+ * controller.signal,
917
+ * fs.createReadStream(('object.json'))
918
+ * );
919
+ * // Later, abort the operation closing the stream
920
+ * controller.abort();
921
+ * ```
922
+ *
923
+ * Or using an `AbortSignal` with a readable stream as an async iterable:
924
+ *
925
+ * ```js
926
+ * const controller = new AbortController();
927
+ * setTimeout(() => controller.abort(), 10_000); // set a timeout
928
+ * const stream = addAbortSignal(
929
+ * controller.signal,
930
+ * fs.createReadStream(('object.json'))
931
+ * );
932
+ * (async () => {
933
+ * try {
934
+ * for await (const chunk of stream) {
935
+ * await process(chunk);
936
+ * }
937
+ * } catch (e) {
938
+ * if (e.name === 'AbortError') {
939
+ * // The operation was cancelled
940
+ * } else {
941
+ * throw e;
942
+ * }
943
+ * }
944
+ * })();
945
+ * ```
946
+ * @since v15.4.0
947
+ * @param signal A signal representing possible cancellation
948
+ * @param stream a stream to attach a signal to
949
+ */
950
+ function addAbortSignal<T extends Stream>(signal: AbortSignal, stream: T): T;
951
+ interface FinishedOptions extends Abortable {
294
952
  error?: boolean | undefined;
295
953
  readable?: boolean | undefined;
296
954
  writable?: boolean | undefined;
297
955
  }
956
+ /**
957
+ * A function to get notified when a stream is no longer readable, writable
958
+ * or has experienced an error or a premature close event.
959
+ *
960
+ * ```js
961
+ * const { finished } = require('stream');
962
+ *
963
+ * const rs = fs.createReadStream('archive.tar');
964
+ *
965
+ * finished(rs, (err) => {
966
+ * if (err) {
967
+ * console.error('Stream failed.', err);
968
+ * } else {
969
+ * console.log('Stream is done reading.');
970
+ * }
971
+ * });
972
+ *
973
+ * rs.resume(); // Drain the stream.
974
+ * ```
975
+ *
976
+ * Especially useful in error handling scenarios where a stream is destroyed
977
+ * prematurely (like an aborted HTTP request), and will not emit `'end'`or `'finish'`.
978
+ *
979
+ * The `finished` API provides promise version:
980
+ *
981
+ * ```js
982
+ * const { finished } = require('stream/promises');
983
+ *
984
+ * const rs = fs.createReadStream('archive.tar');
985
+ *
986
+ * async function run() {
987
+ * await finished(rs);
988
+ * console.log('Stream is done reading.');
989
+ * }
990
+ *
991
+ * run().catch(console.error);
992
+ * rs.resume(); // Drain the stream.
993
+ * ```
994
+ *
995
+ * `stream.finished()` leaves dangling event listeners (in particular`'error'`, `'end'`, `'finish'` and `'close'`) after `callback` has been
996
+ * invoked. The reason for this is so that unexpected `'error'` events (due to
997
+ * incorrect stream implementations) do not cause unexpected crashes.
998
+ * If this is unwanted behavior then the returned cleanup function needs to be
999
+ * invoked in the callback:
1000
+ *
1001
+ * ```js
1002
+ * const cleanup = finished(rs, (err) => {
1003
+ * cleanup();
1004
+ * // ...
1005
+ * });
1006
+ * ```
1007
+ * @since v10.0.0
1008
+ * @param stream A readable and/or writable stream.
1009
+ * @param callback A callback function that takes an optional error argument.
1010
+ * @return A cleanup function which removes all registered listeners.
1011
+ */
298
1012
  function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, options: FinishedOptions, callback: (err?: NodeJS.ErrnoException | null) => void): () => void;
299
1013
  function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, callback: (err?: NodeJS.ErrnoException | null) => void): () => void;
300
1014
  namespace finished {
301
1015
  function __promisify__(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, options?: FinishedOptions): Promise<void>;
302
1016
  }
303
-
304
- function pipeline<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: T, callback?: (err: NodeJS.ErrnoException | null) => void): T;
305
- function pipeline<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: T, callback?: (err: NodeJS.ErrnoException | null) => void): T;
306
- function pipeline<T extends NodeJS.WritableStream>(
307
- stream1: NodeJS.ReadableStream,
308
- stream2: NodeJS.ReadWriteStream,
309
- stream3: NodeJS.ReadWriteStream,
310
- stream4: T,
311
- callback?: (err: NodeJS.ErrnoException | null) => void,
312
- ): T;
313
- function pipeline<T extends NodeJS.WritableStream>(
314
- stream1: NodeJS.ReadableStream,
315
- stream2: NodeJS.ReadWriteStream,
316
- stream3: NodeJS.ReadWriteStream,
317
- stream4: NodeJS.ReadWriteStream,
318
- stream5: T,
319
- callback?: (err: NodeJS.ErrnoException | null) => void,
320
- ): T;
1017
+ type PipelineSourceFunction<T> = () => Iterable<T> | AsyncIterable<T>;
1018
+ type PipelineSource<T> = Iterable<T> | AsyncIterable<T> | NodeJS.ReadableStream | PipelineSourceFunction<T>;
1019
+ type PipelineTransform<S extends PipelineTransformSource<any>, U> =
1020
+ | NodeJS.ReadWriteStream
1021
+ | ((source: S extends (...args: any[]) => Iterable<infer ST> | AsyncIterable<infer ST> ? AsyncIterable<ST> : S) => AsyncIterable<U>);
1022
+ type PipelineTransformSource<T> = PipelineSource<T> | PipelineTransform<any, T>;
1023
+ type PipelineDestinationIterableFunction<T> = (source: AsyncIterable<T>) => AsyncIterable<any>;
1024
+ type PipelineDestinationPromiseFunction<T, P> = (source: AsyncIterable<T>) => Promise<P>;
1025
+ type PipelineDestination<S extends PipelineTransformSource<any>, P> = S extends PipelineTransformSource<infer ST>
1026
+ ? NodeJS.WritableStream | PipelineDestinationIterableFunction<ST> | PipelineDestinationPromiseFunction<ST, P>
1027
+ : never;
1028
+ type PipelineCallback<S extends PipelineDestination<any, any>> = S extends PipelineDestinationPromiseFunction<any, infer P>
1029
+ ? (err: NodeJS.ErrnoException | null, value: P) => void
1030
+ : (err: NodeJS.ErrnoException | null) => void;
1031
+ type PipelinePromise<S extends PipelineDestination<any, any>> = S extends PipelineDestinationPromiseFunction<any, infer P> ? Promise<P> : Promise<void>;
1032
+ interface PipelineOptions {
1033
+ signal: AbortSignal;
1034
+ }
1035
+ /**
1036
+ * A module method to pipe between streams and generators forwarding errors and
1037
+ * properly cleaning up and provide a callback when the pipeline is complete.
1038
+ *
1039
+ * ```js
1040
+ * const { pipeline } = require('stream');
1041
+ * const fs = require('fs');
1042
+ * const zlib = require('zlib');
1043
+ *
1044
+ * // Use the pipeline API to easily pipe a series of streams
1045
+ * // together and get notified when the pipeline is fully done.
1046
+ *
1047
+ * // A pipeline to gzip a potentially huge tar file efficiently:
1048
+ *
1049
+ * pipeline(
1050
+ * fs.createReadStream('archive.tar'),
1051
+ * zlib.createGzip(),
1052
+ * fs.createWriteStream('archive.tar.gz'),
1053
+ * (err) => {
1054
+ * if (err) {
1055
+ * console.error('Pipeline failed.', err);
1056
+ * } else {
1057
+ * console.log('Pipeline succeeded.');
1058
+ * }
1059
+ * }
1060
+ * );
1061
+ * ```
1062
+ *
1063
+ * The `pipeline` API provides a promise version, which can also
1064
+ * receive an options argument as the last parameter with a`signal` `AbortSignal` property. When the signal is aborted,`destroy` will be called on the underlying pipeline, with
1065
+ * an`AbortError`.
1066
+ *
1067
+ * ```js
1068
+ * const { pipeline } = require('stream/promises');
1069
+ *
1070
+ * async function run() {
1071
+ * await pipeline(
1072
+ * fs.createReadStream('archive.tar'),
1073
+ * zlib.createGzip(),
1074
+ * fs.createWriteStream('archive.tar.gz')
1075
+ * );
1076
+ * console.log('Pipeline succeeded.');
1077
+ * }
1078
+ *
1079
+ * run().catch(console.error);
1080
+ * ```
1081
+ *
1082
+ * To use an `AbortSignal`, pass it inside an options object,
1083
+ * as the last argument:
1084
+ *
1085
+ * ```js
1086
+ * const { pipeline } = require('stream/promises');
1087
+ *
1088
+ * async function run() {
1089
+ * const ac = new AbortController();
1090
+ * const signal = ac.signal;
1091
+ *
1092
+ * setTimeout(() => ac.abort(), 1);
1093
+ * await pipeline(
1094
+ * fs.createReadStream('archive.tar'),
1095
+ * zlib.createGzip(),
1096
+ * fs.createWriteStream('archive.tar.gz'),
1097
+ * { signal },
1098
+ * );
1099
+ * }
1100
+ *
1101
+ * run().catch(console.error); // AbortError
1102
+ * ```
1103
+ *
1104
+ * The `pipeline` API also supports async generators:
1105
+ *
1106
+ * ```js
1107
+ * const { pipeline } = require('stream/promises');
1108
+ * const fs = require('fs');
1109
+ *
1110
+ * async function run() {
1111
+ * await pipeline(
1112
+ * fs.createReadStream('lowercase.txt'),
1113
+ * async function* (source, signal) {
1114
+ * source.setEncoding('utf8'); // Work with strings rather than `Buffer`s.
1115
+ * for await (const chunk of source) {
1116
+ * yield await processChunk(chunk, { signal });
1117
+ * }
1118
+ * },
1119
+ * fs.createWriteStream('uppercase.txt')
1120
+ * );
1121
+ * console.log('Pipeline succeeded.');
1122
+ * }
1123
+ *
1124
+ * run().catch(console.error);
1125
+ * ```
1126
+ *
1127
+ * Remember to handle the `signal` argument passed into the async generator.
1128
+ * Especially in the case where the async generator is the source for the
1129
+ * pipeline (i.e. first argument) or the pipeline will never complete.
1130
+ *
1131
+ * ```js
1132
+ * const { pipeline } = require('stream/promises');
1133
+ * const fs = require('fs');
1134
+ *
1135
+ * async function run() {
1136
+ * await pipeline(
1137
+ * async function * (signal) {
1138
+ * await someLongRunningfn({ signal });
1139
+ * yield 'asd';
1140
+ * },
1141
+ * fs.createWriteStream('uppercase.txt')
1142
+ * );
1143
+ * console.log('Pipeline succeeded.');
1144
+ * }
1145
+ *
1146
+ * run().catch(console.error);
1147
+ * ```
1148
+ *
1149
+ * `stream.pipeline()` will call `stream.destroy(err)` on all streams except:
1150
+ *
1151
+ * * `Readable` streams which have emitted `'end'` or `'close'`.
1152
+ * * `Writable` streams which have emitted `'finish'` or `'close'`.
1153
+ *
1154
+ * `stream.pipeline()` leaves dangling event listeners on the streams
1155
+ * after the `callback` has been invoked. In the case of reuse of streams after
1156
+ * failure, this can cause event listener leaks and swallowed errors.
1157
+ * @since v10.0.0
1158
+ * @param callback Called when the pipeline is fully done.
1159
+ */
1160
+ function pipeline<A extends PipelineSource<any>, B extends PipelineDestination<A, any>>(
1161
+ source: A,
1162
+ destination: B,
1163
+ callback?: PipelineCallback<B>
1164
+ ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
1165
+ function pipeline<A extends PipelineSource<any>, T1 extends PipelineTransform<A, any>, B extends PipelineDestination<T1, any>>(
1166
+ source: A,
1167
+ transform1: T1,
1168
+ destination: B,
1169
+ callback?: PipelineCallback<B>
1170
+ ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
1171
+ function pipeline<A extends PipelineSource<any>, T1 extends PipelineTransform<A, any>, T2 extends PipelineTransform<T1, any>, B extends PipelineDestination<T2, any>>(
1172
+ source: A,
1173
+ transform1: T1,
1174
+ transform2: T2,
1175
+ destination: B,
1176
+ callback?: PipelineCallback<B>
1177
+ ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
1178
+ function pipeline<
1179
+ A extends PipelineSource<any>,
1180
+ T1 extends PipelineTransform<A, any>,
1181
+ T2 extends PipelineTransform<T1, any>,
1182
+ T3 extends PipelineTransform<T2, any>,
1183
+ B extends PipelineDestination<T3, any>
1184
+ >(source: A, transform1: T1, transform2: T2, transform3: T3, destination: B, callback?: PipelineCallback<B>): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
1185
+ function pipeline<
1186
+ A extends PipelineSource<any>,
1187
+ T1 extends PipelineTransform<A, any>,
1188
+ T2 extends PipelineTransform<T1, any>,
1189
+ T3 extends PipelineTransform<T2, any>,
1190
+ T4 extends PipelineTransform<T3, any>,
1191
+ B extends PipelineDestination<T4, any>
1192
+ >(source: A, transform1: T1, transform2: T2, transform3: T3, transform4: T4, destination: B, callback?: PipelineCallback<B>): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
321
1193
  function pipeline(
322
1194
  streams: ReadonlyArray<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>,
323
- callback?: (err: NodeJS.ErrnoException | null) => void,
1195
+ callback?: (err: NodeJS.ErrnoException | null) => void
324
1196
  ): NodeJS.WritableStream;
325
1197
  function pipeline(
326
1198
  stream1: NodeJS.ReadableStream,
327
1199
  stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
328
- ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | ((err: NodeJS.ErrnoException | null) => void)>,
1200
+ ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | ((err: NodeJS.ErrnoException | null) => void)>
329
1201
  ): NodeJS.WritableStream;
330
1202
  namespace pipeline {
331
- function __promisify__(stream1: NodeJS.ReadableStream, stream2: NodeJS.WritableStream): Promise<void>;
332
- function __promisify__(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: NodeJS.WritableStream): Promise<void>;
333
- function __promisify__(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: NodeJS.ReadWriteStream, stream4: NodeJS.WritableStream): Promise<void>;
334
- function __promisify__(
335
- stream1: NodeJS.ReadableStream,
336
- stream2: NodeJS.ReadWriteStream,
337
- stream3: NodeJS.ReadWriteStream,
338
- stream4: NodeJS.ReadWriteStream,
339
- stream5: NodeJS.WritableStream,
340
- ): Promise<void>;
341
- function __promisify__(streams: ReadonlyArray<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>): Promise<void>;
1203
+ function __promisify__<A extends PipelineSource<any>, B extends PipelineDestination<A, any>>(source: A, destination: B, options?: PipelineOptions): PipelinePromise<B>;
1204
+ function __promisify__<A extends PipelineSource<any>, T1 extends PipelineTransform<A, any>, B extends PipelineDestination<T1, any>>(
1205
+ source: A,
1206
+ transform1: T1,
1207
+ destination: B,
1208
+ options?: PipelineOptions
1209
+ ): PipelinePromise<B>;
1210
+ function __promisify__<A extends PipelineSource<any>, T1 extends PipelineTransform<A, any>, T2 extends PipelineTransform<T1, any>, B extends PipelineDestination<T2, any>>(
1211
+ source: A,
1212
+ transform1: T1,
1213
+ transform2: T2,
1214
+ destination: B,
1215
+ options?: PipelineOptions
1216
+ ): PipelinePromise<B>;
1217
+ function __promisify__<
1218
+ A extends PipelineSource<any>,
1219
+ T1 extends PipelineTransform<A, any>,
1220
+ T2 extends PipelineTransform<T1, any>,
1221
+ T3 extends PipelineTransform<T2, any>,
1222
+ B extends PipelineDestination<T3, any>
1223
+ >(source: A, transform1: T1, transform2: T2, transform3: T3, destination: B, options?: PipelineOptions): PipelinePromise<B>;
1224
+ function __promisify__<
1225
+ A extends PipelineSource<any>,
1226
+ T1 extends PipelineTransform<A, any>,
1227
+ T2 extends PipelineTransform<T1, any>,
1228
+ T3 extends PipelineTransform<T2, any>,
1229
+ T4 extends PipelineTransform<T3, any>,
1230
+ B extends PipelineDestination<T4, any>
1231
+ >(source: A, transform1: T1, transform2: T2, transform3: T3, transform4: T4, destination: B, options?: PipelineOptions): PipelinePromise<B>;
1232
+ function __promisify__(streams: ReadonlyArray<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>, options?: PipelineOptions): Promise<void>;
342
1233
  function __promisify__(
343
1234
  stream1: NodeJS.ReadableStream,
344
1235
  stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
345
- ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream>,
1236
+ ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | PipelineOptions>
346
1237
  ): Promise<void>;
347
1238
  }
348
-
349
1239
  interface Pipe {
350
1240
  close(): void;
351
1241
  hasRef(): boolean;
352
1242
  ref(): void;
353
1243
  unref(): void;
354
1244
  }
355
- }
356
1245
 
1246
+ /**
1247
+ * Returns whether the stream has encountered an error.
1248
+ * @since v16.14.0
1249
+ */
1250
+ function isErrored(stream: Readable | Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean;
1251
+
1252
+ /**
1253
+ * Returns whether the stream is readable.
1254
+ * @since v16.14.0
1255
+ */
1256
+ function isReadable(stream: Readable | NodeJS.ReadableStream): boolean;
1257
+
1258
+ const promises: typeof streamPromises;
1259
+ const consumers: typeof streamConsumers;
1260
+ }
357
1261
  export = internal;
358
1262
  }
359
1263
  declare module 'node:stream' {