@types/node 20.12.11 → 20.12.12
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/README.md +1 -1
- node/package.json +2 -2
- node/stream.d.ts +50 -46
node/README.md
CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
9
9
|
|
10
10
|
### Additional Details
|
11
|
-
* Last updated:
|
11
|
+
* Last updated: Tue, 14 May 2024 06:09:35 GMT
|
12
12
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
13
13
|
|
14
14
|
# Credits
|
node/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@types/node",
|
3
|
-
"version": "20.12.
|
3
|
+
"version": "20.12.12",
|
4
4
|
"description": "TypeScript definitions for node",
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
6
6
|
"license": "MIT",
|
@@ -212,6 +212,6 @@
|
|
212
212
|
"dependencies": {
|
213
213
|
"undici-types": "~5.26.4"
|
214
214
|
},
|
215
|
-
"typesPublisherContentHash": "
|
215
|
+
"typesPublisherContentHash": "402e23fae4726c16c2a42ec4d2c7348a15cefadefe71ba6808b89ecca3e73a79",
|
216
216
|
"typeScriptVersion": "4.7"
|
217
217
|
}
|
node/stream.d.ts
CHANGED
@@ -2,9 +2,10 @@
|
|
2
2
|
* A stream is an abstract interface for working with streaming data in Node.js.
|
3
3
|
* The `node:stream` module provides an API for implementing the stream interface.
|
4
4
|
*
|
5
|
-
* There are many stream objects provided by Node.js. For instance, a
|
5
|
+
* There are many stream objects provided by Node.js. For instance, a [request to an HTTP server](https://nodejs.org/docs/latest-v20.x/api/http.html#class-httpincomingmessage)
|
6
|
+
* and [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) are both stream instances.
|
6
7
|
*
|
7
|
-
* Streams can be readable, writable, or both. All streams are instances of `EventEmitter
|
8
|
+
* Streams can be readable, writable, or both. All streams are instances of [`EventEmitter`](https://nodejs.org/docs/latest-v20.x/api/events.html#class-eventemitter).
|
8
9
|
*
|
9
10
|
* To access the `node:stream` module:
|
10
11
|
*
|
@@ -41,16 +42,20 @@ declare module "stream" {
|
|
41
42
|
import Readable = internal.Readable;
|
42
43
|
import ReadableOptions = internal.ReadableOptions;
|
43
44
|
interface ArrayOptions {
|
44
|
-
/**
|
45
|
+
/**
|
46
|
+
* The maximum concurrent invocations of `fn` to call on the stream at once.
|
45
47
|
* @default 1
|
46
48
|
*/
|
47
49
|
concurrency?: number;
|
48
|
-
/**
|
50
|
+
/** Allows destroying the stream if the signal is aborted. */
|
49
51
|
signal?: AbortSignal;
|
50
52
|
}
|
51
53
|
class ReadableBase extends Stream implements NodeJS.ReadableStream {
|
52
54
|
/**
|
53
55
|
* A utility method for creating Readable Streams out of iterators.
|
56
|
+
* @since v12.3.0, v10.17.0
|
57
|
+
* @param iterable Object implementing the `Symbol.asyncIterator` or `Symbol.iterator` iterable protocol. Emits an 'error' event if a null value is passed.
|
58
|
+
* @param options Options provided to `new stream.Readable([options])`. By default, `Readable.from()` will set `options.objectMode` to `true`, unless this is explicitly opted out by setting `options.objectMode` to `false`.
|
54
59
|
*/
|
55
60
|
static from(iterable: Iterable<any> | AsyncIterable<any>, options?: ReadableOptions): Readable;
|
56
61
|
/**
|
@@ -65,7 +70,7 @@ declare module "stream" {
|
|
65
70
|
*/
|
66
71
|
readonly readableAborted: boolean;
|
67
72
|
/**
|
68
|
-
* Is `true` if it is safe to call
|
73
|
+
* Is `true` if it is safe to call {@link read}, which means
|
69
74
|
* the stream has not been destroyed or emitted `'error'` or `'end'`.
|
70
75
|
* @since v11.4.0
|
71
76
|
*/
|
@@ -77,18 +82,18 @@ declare module "stream" {
|
|
77
82
|
*/
|
78
83
|
readonly readableDidRead: boolean;
|
79
84
|
/**
|
80
|
-
* Getter for the property `encoding` of a given `Readable` stream. The `encoding` property can be set using the
|
85
|
+
* Getter for the property `encoding` of a given `Readable` stream. The `encoding` property can be set using the {@link setEncoding} method.
|
81
86
|
* @since v12.7.0
|
82
87
|
*/
|
83
88
|
readonly readableEncoding: BufferEncoding | null;
|
84
89
|
/**
|
85
|
-
* Becomes `true` when `'end'` event is emitted.
|
90
|
+
* Becomes `true` when [`'end'`](https://nodejs.org/docs/latest-v20.x/api/stream.html#event-end) event is emitted.
|
86
91
|
* @since v12.9.0
|
87
92
|
*/
|
88
93
|
readonly readableEnded: boolean;
|
89
94
|
/**
|
90
95
|
* This property reflects the current state of a `Readable` stream as described
|
91
|
-
* in the
|
96
|
+
* in the [Three states](https://nodejs.org/docs/latest-v20.x/api/stream.html#three-states) section.
|
92
97
|
* @since v9.4.0
|
93
98
|
*/
|
94
99
|
readonly readableFlowing: boolean | null;
|
@@ -134,9 +139,10 @@ declare module "stream" {
|
|
134
139
|
* specified using the `readable.setEncoding()` method or the stream is operating
|
135
140
|
* in object mode.
|
136
141
|
*
|
137
|
-
* The optional `size` argument specifies a specific number of bytes to read. If
|
138
|
-
*
|
139
|
-
*
|
142
|
+
* The optional `size` argument specifies a specific number of bytes to read. If
|
143
|
+
* `size` bytes are not available to be read, `null` will be returned _unless_ the
|
144
|
+
* stream has ended, in which case all of the data remaining in the internal buffer
|
145
|
+
* will be returned.
|
140
146
|
*
|
141
147
|
* If the `size` argument is not specified, all of the data contained in the
|
142
148
|
* internal buffer will be returned.
|
@@ -193,7 +199,7 @@ declare module "stream" {
|
|
193
199
|
* ```
|
194
200
|
*
|
195
201
|
* A `Readable` stream in object mode will always return a single item from
|
196
|
-
* a call to `readable.read(size)`, regardless of the value of the`size` argument.
|
202
|
+
* a call to `readable.read(size)`, regardless of the value of the `size` argument.
|
197
203
|
*
|
198
204
|
* If the `readable.read()` method returns a chunk of data, a `'data'` event will
|
199
205
|
* also be emitted.
|
@@ -208,9 +214,9 @@ declare module "stream" {
|
|
208
214
|
* The `readable.setEncoding()` method sets the character encoding for
|
209
215
|
* data read from the `Readable` stream.
|
210
216
|
*
|
211
|
-
* By default, no encoding is assigned and stream data will be returned as`Buffer` objects. Setting an encoding causes the stream data
|
217
|
+
* By default, no encoding is assigned and stream data will be returned as `Buffer` objects. Setting an encoding causes the stream data
|
212
218
|
* to be returned as strings of the specified encoding rather than as `Buffer` objects. For instance, calling `readable.setEncoding('utf8')` will cause the
|
213
|
-
* 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
|
219
|
+
* 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
|
214
220
|
* string format.
|
215
221
|
*
|
216
222
|
* The `Readable` stream will properly handle multi-byte characters delivered
|
@@ -247,7 +253,7 @@ declare module "stream" {
|
|
247
253
|
* });
|
248
254
|
* ```
|
249
255
|
*
|
250
|
-
* The `readable.pause()` method has no effect if there is a `'readable'`event listener.
|
256
|
+
* The `readable.pause()` method has no effect if there is a `'readable'` event listener.
|
251
257
|
* @since v0.9.4
|
252
258
|
*/
|
253
259
|
pause(): this;
|
@@ -271,9 +277,9 @@ declare module "stream" {
|
|
271
277
|
*/
|
272
278
|
resume(): this;
|
273
279
|
/**
|
274
|
-
* The `readable.isPaused()` method returns the current operating state of the`Readable`. This is
|
275
|
-
*
|
276
|
-
* use this method directly.
|
280
|
+
* The `readable.isPaused()` method returns the current operating state of the `Readable`. This is
|
281
|
+
* used primarily by the mechanism that underlies the `readable.pipe()` method. In most typical cases,
|
282
|
+
* there will be no reason to use this method directly.
|
277
283
|
*
|
278
284
|
* ```js
|
279
285
|
* const readable = new stream.Readable();
|
@@ -384,7 +390,7 @@ declare module "stream" {
|
|
384
390
|
* Prior to Node.js 0.10, streams did not implement the entire `node:stream` module API as it is currently defined. (See `Compatibility` for more
|
385
391
|
* information.)
|
386
392
|
*
|
387
|
-
* 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`
|
393
|
+
* 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`
|
388
394
|
* stream that uses
|
389
395
|
* the old stream as its data source.
|
390
396
|
*
|
@@ -567,8 +573,8 @@ declare module "stream" {
|
|
567
573
|
): Promise<T>;
|
568
574
|
_destroy(error: Error | null, callback: (error?: Error | null) => void): void;
|
569
575
|
/**
|
570
|
-
* Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the readable
|
571
|
-
* stream will release any internal resources and subsequent calls to `push()`will be ignored.
|
576
|
+
* Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'` event (unless `emitClose` is set to `false`). After this call, the readable
|
577
|
+
* stream will release any internal resources and subsequent calls to `push()` will be ignored.
|
572
578
|
*
|
573
579
|
* Once `destroy()` has been called any further calls will be a no-op and no
|
574
580
|
* further errors except from `_destroy()` may be emitted as `'error'`.
|
@@ -733,7 +739,7 @@ declare module "stream" {
|
|
733
739
|
* first argument. The `callback` is called asynchronously and before `'error'` is
|
734
740
|
* emitted.
|
735
741
|
*
|
736
|
-
* The return value is `true` if the internal buffer is less than the`highWaterMark` configured when the stream was created after admitting `chunk`.
|
742
|
+
* The return value is `true` if the internal buffer is less than the `highWaterMark` configured when the stream was created after admitting `chunk`.
|
737
743
|
* If `false` is returned, further attempts to write data to the stream should
|
738
744
|
* stop until the `'drain'` event is emitted.
|
739
745
|
*
|
@@ -821,10 +827,10 @@ declare module "stream" {
|
|
821
827
|
*
|
822
828
|
* The primary intent of `writable.cork()` is to accommodate a situation in which
|
823
829
|
* several small chunks are written to the stream in rapid succession. Instead of
|
824
|
-
* immediately forwarding them to the underlying destination, `writable.cork()`buffers all the chunks until `writable.uncork()` is called, which will pass them
|
830
|
+
* immediately forwarding them to the underlying destination, `writable.cork()` buffers all the chunks until `writable.uncork()` is called, which will pass them
|
825
831
|
* all to `writable._writev()`, if present. This prevents a head-of-line blocking
|
826
832
|
* situation where data is being buffered while waiting for the first small chunk
|
827
|
-
* to be processed. However, use of `writable.cork()` without implementing`writable._writev()` may have an adverse effect on throughput.
|
833
|
+
* to be processed. However, use of `writable.cork()` without implementing `writable._writev()` may have an adverse effect on throughput.
|
828
834
|
*
|
829
835
|
* See also: `writable.uncork()`, `writable._writev()`.
|
830
836
|
* @since v0.11.2
|
@@ -834,7 +840,7 @@ declare module "stream" {
|
|
834
840
|
* The `writable.uncork()` method flushes all data buffered since {@link cork} was called.
|
835
841
|
*
|
836
842
|
* When using `writable.cork()` and `writable.uncork()` to manage the buffering
|
837
|
-
* of writes to a stream, defer calls to `writable.uncork()` using`process.nextTick()`. Doing so allows batching of all`writable.write()` calls that occur within a given Node.js event
|
843
|
+
* of writes to a stream, defer calls to `writable.uncork()` using `process.nextTick()`. Doing so allows batching of all `writable.write()` calls that occur within a given Node.js event
|
838
844
|
* loop phase.
|
839
845
|
*
|
840
846
|
* ```js
|
@@ -865,10 +871,10 @@ declare module "stream" {
|
|
865
871
|
*/
|
866
872
|
uncork(): void;
|
867
873
|
/**
|
868
|
-
* Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the writable
|
874
|
+
* Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'` event (unless `emitClose` is set to `false`). After this call, the writable
|
869
875
|
* stream has ended and subsequent calls to `write()` or `end()` will result in
|
870
876
|
* an `ERR_STREAM_DESTROYED` error.
|
871
|
-
* 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.
|
877
|
+
* 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.
|
872
878
|
* Use `end()` instead of destroy if data should flush before close, or wait for
|
873
879
|
* the `'drain'` event before destroying the stream.
|
874
880
|
*
|
@@ -1063,8 +1069,8 @@ declare module "stream" {
|
|
1063
1069
|
* readable side ends. Set initially by the `allowHalfOpen` constructor option,
|
1064
1070
|
* which defaults to `true`.
|
1065
1071
|
*
|
1066
|
-
* This can be changed manually to change the half-open behavior of an existing
|
1067
|
-
* emitted.
|
1072
|
+
* This can be changed manually to change the half-open behavior of an existing
|
1073
|
+
* `Duplex` stream instance, but must be changed before the `'end'` event is emitted.
|
1068
1074
|
* @since v0.9.4
|
1069
1075
|
*/
|
1070
1076
|
allowHalfOpen: boolean;
|
@@ -1285,7 +1291,7 @@ declare module "stream" {
|
|
1285
1291
|
}
|
1286
1292
|
/**
|
1287
1293
|
* 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
|
1288
|
-
* 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.
|
1294
|
+
* 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.
|
1289
1295
|
*/
|
1290
1296
|
class PassThrough extends Transform {}
|
1291
1297
|
/**
|
@@ -1294,8 +1300,8 @@ declare module "stream" {
|
|
1294
1300
|
* Attaches an AbortSignal to a readable or writeable stream. This lets code
|
1295
1301
|
* control stream destruction using an `AbortController`.
|
1296
1302
|
*
|
1297
|
-
* Calling `abort` on the `AbortController` corresponding to the passed`AbortSignal` will behave the same way as
|
1298
|
-
* AbortError())` for webstreams.
|
1303
|
+
* Calling `abort` on the `AbortController` corresponding to the passed `AbortSignal` will behave the same way as
|
1304
|
+
* calling `.destroy(new AbortError())` on the stream, and `controller.error(new AbortError())` for webstreams.
|
1299
1305
|
*
|
1300
1306
|
* ```js
|
1301
1307
|
* const fs = require('node:fs');
|
@@ -1365,20 +1371,18 @@ declare module "stream" {
|
|
1365
1371
|
* ```
|
1366
1372
|
* @since v15.4.0
|
1367
1373
|
* @param signal A signal representing possible cancellation
|
1368
|
-
* @param stream
|
1374
|
+
* @param stream A stream to attach a signal to.
|
1369
1375
|
*/
|
1370
1376
|
function addAbortSignal<T extends Stream>(signal: AbortSignal, stream: T): T;
|
1371
1377
|
/**
|
1372
1378
|
* Returns the default highWaterMark used by streams.
|
1373
1379
|
* Defaults to `16384` (16 KiB), or `16` for `objectMode`.
|
1374
1380
|
* @since v19.9.0
|
1375
|
-
* @param objectMode
|
1376
1381
|
*/
|
1377
1382
|
function getDefaultHighWaterMark(objectMode: boolean): number;
|
1378
1383
|
/**
|
1379
1384
|
* Sets the default highWaterMark used by streams.
|
1380
1385
|
* @since v19.9.0
|
1381
|
-
* @param objectMode
|
1382
1386
|
* @param value highWaterMark value
|
1383
1387
|
*/
|
1384
1388
|
function setDefaultHighWaterMark(objectMode: boolean, value: number): void;
|
@@ -1411,11 +1415,11 @@ declare module "stream" {
|
|
1411
1415
|
* ```
|
1412
1416
|
*
|
1413
1417
|
* Especially useful in error handling scenarios where a stream is destroyed
|
1414
|
-
* prematurely (like an aborted HTTP request), and will not emit `'end'`or `'finish'`.
|
1418
|
+
* prematurely (like an aborted HTTP request), and will not emit `'end'` or `'finish'`.
|
1415
1419
|
*
|
1416
|
-
* The `finished` API provides
|
1420
|
+
* The `finished` API provides [promise version](https://nodejs.org/docs/latest-v20.x/api/stream.html#streamfinishedstream-options).
|
1417
1421
|
*
|
1418
|
-
* `stream.finished()` leaves dangling event listeners (in particular`'error'`, `'end'`, `'finish'` and `'close'`) after `callback` has been
|
1422
|
+
* `stream.finished()` leaves dangling event listeners (in particular `'error'`, `'end'`, `'finish'` and `'close'`) after `callback` has been
|
1419
1423
|
* invoked. The reason for this is so that unexpected `'error'` events (due to
|
1420
1424
|
* incorrect stream implementations) do not cause unexpected crashes.
|
1421
1425
|
* If this is unwanted behavior then the returned cleanup function needs to be
|
@@ -1430,7 +1434,7 @@ declare module "stream" {
|
|
1430
1434
|
* @since v10.0.0
|
1431
1435
|
* @param stream A readable and/or writable stream.
|
1432
1436
|
* @param callback A callback function that takes an optional error argument.
|
1433
|
-
* @
|
1437
|
+
* @returns A cleanup function which removes all registered listeners.
|
1434
1438
|
*/
|
1435
1439
|
function finished(
|
1436
1440
|
stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream,
|
@@ -1501,7 +1505,7 @@ declare module "stream" {
|
|
1501
1505
|
* );
|
1502
1506
|
* ```
|
1503
1507
|
*
|
1504
|
-
* The `pipeline` API provides a
|
1508
|
+
* The `pipeline` API provides a [promise version](https://nodejs.org/docs/latest-v20.x/api/stream.html#streampipelinesource-transforms-destination-options).
|
1505
1509
|
*
|
1506
1510
|
* `stream.pipeline()` will call `stream.destroy(err)` on all streams except:
|
1507
1511
|
*
|
@@ -1541,7 +1545,7 @@ declare module "stream" {
|
|
1541
1545
|
function pipeline<A extends PipelineSource<any>, B extends PipelineDestination<A, any>>(
|
1542
1546
|
source: A,
|
1543
1547
|
destination: B,
|
1544
|
-
callback
|
1548
|
+
callback: PipelineCallback<B>,
|
1545
1549
|
): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
|
1546
1550
|
function pipeline<
|
1547
1551
|
A extends PipelineSource<any>,
|
@@ -1551,7 +1555,7 @@ declare module "stream" {
|
|
1551
1555
|
source: A,
|
1552
1556
|
transform1: T1,
|
1553
1557
|
destination: B,
|
1554
|
-
callback
|
1558
|
+
callback: PipelineCallback<B>,
|
1555
1559
|
): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
|
1556
1560
|
function pipeline<
|
1557
1561
|
A extends PipelineSource<any>,
|
@@ -1563,7 +1567,7 @@ declare module "stream" {
|
|
1563
1567
|
transform1: T1,
|
1564
1568
|
transform2: T2,
|
1565
1569
|
destination: B,
|
1566
|
-
callback
|
1570
|
+
callback: PipelineCallback<B>,
|
1567
1571
|
): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
|
1568
1572
|
function pipeline<
|
1569
1573
|
A extends PipelineSource<any>,
|
@@ -1577,7 +1581,7 @@ declare module "stream" {
|
|
1577
1581
|
transform2: T2,
|
1578
1582
|
transform3: T3,
|
1579
1583
|
destination: B,
|
1580
|
-
callback
|
1584
|
+
callback: PipelineCallback<B>,
|
1581
1585
|
): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
|
1582
1586
|
function pipeline<
|
1583
1587
|
A extends PipelineSource<any>,
|
@@ -1593,11 +1597,11 @@ declare module "stream" {
|
|
1593
1597
|
transform3: T3,
|
1594
1598
|
transform4: T4,
|
1595
1599
|
destination: B,
|
1596
|
-
callback
|
1600
|
+
callback: PipelineCallback<B>,
|
1597
1601
|
): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream;
|
1598
1602
|
function pipeline(
|
1599
1603
|
streams: ReadonlyArray<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>,
|
1600
|
-
callback
|
1604
|
+
callback: (err: NodeJS.ErrnoException | null) => void,
|
1601
1605
|
): NodeJS.WritableStream;
|
1602
1606
|
function pipeline(
|
1603
1607
|
stream1: NodeJS.ReadableStream,
|