@types/node 16.18.110 → 16.18.111
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 v16.18/README.md +1 -1
- node v16.18/buffer.d.ts +1 -1
- node v16.18/child_process.d.ts +34 -29
- node v16.18/cluster.d.ts +1 -1
- node v16.18/console.d.ts +2 -2
- node v16.18/crypto.d.ts +1 -1
- node v16.18/dns/promises.d.ts +6 -5
- node v16.18/dns.d.ts +5 -5
- node v16.18/domain.d.ts +2 -2
- node v16.18/events.d.ts +13 -13
- node v16.18/fs/promises.d.ts +2 -2
- node v16.18/fs.d.ts +1 -1
- node v16.18/http.d.ts +2 -2
- node v16.18/http2.d.ts +24 -24
- node v16.18/https.d.ts +9 -9
- node v16.18/inspector.d.ts +1 -1
- node v16.18/module.d.ts +3 -3
- node v16.18/net.d.ts +2 -2
- node v16.18/os.d.ts +1 -1
- node v16.18/package.json +2 -2
- node v16.18/path.d.ts +1 -1
- node v16.18/perf_hooks.d.ts +11 -11
- node v16.18/punycode.d.ts +1 -1
- node v16.18/querystring.d.ts +1 -1
- node v16.18/readline.d.ts +12 -12
- node v16.18/repl.d.ts +4 -4
- node v16.18/stream.d.ts +18 -18
- node v16.18/string_decoder.d.ts +3 -3
- node v16.18/timers/promises.d.ts +1 -1
- node v16.18/timers.d.ts +1 -1
- node v16.18/tls.d.ts +5 -5
- node v16.18/trace_events.d.ts +3 -3
- node v16.18/tty.d.ts +1 -1
- node v16.18/url.d.ts +6 -6
- node v16.18/util.d.ts +40 -40
- node v16.18/v8.d.ts +11 -11
- node v16.18/vm.d.ts +11 -12
- node v16.18/worker_threads.d.ts +19 -19
- node v16.18/zlib.d.ts +8 -8
node v16.18/http2.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* It can be accessed using:
|
|
4
4
|
*
|
|
5
5
|
* ```js
|
|
6
|
-
*
|
|
6
|
+
* import http2 from 'node:http2';
|
|
7
7
|
* ```
|
|
8
8
|
* @since v8.4.0
|
|
9
9
|
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/http2.js)
|
|
@@ -157,7 +157,7 @@ declare module "http2" {
|
|
|
157
157
|
priority(options: StreamPriorityOptions): void;
|
|
158
158
|
/**
|
|
159
159
|
* ```js
|
|
160
|
-
*
|
|
160
|
+
* import http2 from 'node:http2';
|
|
161
161
|
* const client = http2.connect('http://example.org:8000');
|
|
162
162
|
* const { NGHTTP2_CANCEL } = http2.constants;
|
|
163
163
|
* const req = client.request({ ':path': '/' });
|
|
@@ -177,7 +177,7 @@ declare module "http2" {
|
|
|
177
177
|
* trailers can be sent.
|
|
178
178
|
*
|
|
179
179
|
* ```js
|
|
180
|
-
*
|
|
180
|
+
* import http2 from 'node:http2';
|
|
181
181
|
* const server = http2.createServer();
|
|
182
182
|
* server.on('stream', (stream) => {
|
|
183
183
|
* stream.respond(undefined, { waitForTrailers: true });
|
|
@@ -368,7 +368,7 @@ declare module "http2" {
|
|
|
368
368
|
* Initiates a push stream. The callback is invoked with the new `Http2Stream` instance created for the push stream passed as the second argument, or an `Error` passed as the first argument.
|
|
369
369
|
*
|
|
370
370
|
* ```js
|
|
371
|
-
*
|
|
371
|
+
* import http2 from 'node:http2';
|
|
372
372
|
* const server = http2.createServer();
|
|
373
373
|
* server.on('stream', (stream) => {
|
|
374
374
|
* stream.respond({ ':status': 200 });
|
|
@@ -400,7 +400,7 @@ declare module "http2" {
|
|
|
400
400
|
): void;
|
|
401
401
|
/**
|
|
402
402
|
* ```js
|
|
403
|
-
*
|
|
403
|
+
* import http2 from 'node:http2';
|
|
404
404
|
* const server = http2.createServer();
|
|
405
405
|
* server.on('stream', (stream) => {
|
|
406
406
|
* stream.respond({ ':status': 200 });
|
|
@@ -416,7 +416,7 @@ declare module "http2" {
|
|
|
416
416
|
* close when the final `DATA` frame is transmitted. User code must call either `http2stream.sendTrailers()` or `http2stream.close()` to close the `Http2Stream`.
|
|
417
417
|
*
|
|
418
418
|
* ```js
|
|
419
|
-
*
|
|
419
|
+
* import http2 from 'node:http2';
|
|
420
420
|
* const server = http2.createServer();
|
|
421
421
|
* server.on('stream', (stream) => {
|
|
422
422
|
* stream.respond({ ':status': 200 }, { waitForTrailers: true });
|
|
@@ -439,8 +439,8 @@ declare module "http2" {
|
|
|
439
439
|
* automatically.
|
|
440
440
|
*
|
|
441
441
|
* ```js
|
|
442
|
-
*
|
|
443
|
-
*
|
|
442
|
+
* import http2 from 'node:http2';
|
|
443
|
+
* import fs from 'node:fs';
|
|
444
444
|
*
|
|
445
445
|
* const server = http2.createServer();
|
|
446
446
|
* server.on('stream', (stream) => {
|
|
@@ -482,8 +482,8 @@ declare module "http2" {
|
|
|
482
482
|
* or `http2stream.close()` to close the `Http2Stream`.
|
|
483
483
|
*
|
|
484
484
|
* ```js
|
|
485
|
-
*
|
|
486
|
-
*
|
|
485
|
+
* import http2 from 'node:http2';
|
|
486
|
+
* import fs from 'node:fs';
|
|
487
487
|
*
|
|
488
488
|
* const server = http2.createServer();
|
|
489
489
|
* server.on('stream', (stream) => {
|
|
@@ -529,7 +529,7 @@ declare module "http2" {
|
|
|
529
529
|
* Example using a file path:
|
|
530
530
|
*
|
|
531
531
|
* ```js
|
|
532
|
-
*
|
|
532
|
+
* import http2 from 'node:http2';
|
|
533
533
|
* const server = http2.createServer();
|
|
534
534
|
* server.on('stream', (stream) => {
|
|
535
535
|
* function statCheck(stat, headers) {
|
|
@@ -563,7 +563,7 @@ declare module "http2" {
|
|
|
563
563
|
* results to determine if the file has been modified to return an appropriate `304` response:
|
|
564
564
|
*
|
|
565
565
|
* ```js
|
|
566
|
-
*
|
|
566
|
+
* import http2 from 'node:http2';
|
|
567
567
|
* const server = http2.createServer();
|
|
568
568
|
* server.on('stream', (stream) => {
|
|
569
569
|
* function statCheck(stat, headers) {
|
|
@@ -596,7 +596,7 @@ declare module "http2" {
|
|
|
596
596
|
* close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.
|
|
597
597
|
*
|
|
598
598
|
* ```js
|
|
599
|
-
*
|
|
599
|
+
* import http2 from 'node:http2';
|
|
600
600
|
* const server = http2.createServer();
|
|
601
601
|
* server.on('stream', (stream) => {
|
|
602
602
|
* stream.respondWithFile('/some/file',
|
|
@@ -805,7 +805,7 @@ declare module "http2" {
|
|
|
805
805
|
* the delta.
|
|
806
806
|
*
|
|
807
807
|
* ```js
|
|
808
|
-
*
|
|
808
|
+
* import http2 from 'node:http2';
|
|
809
809
|
*
|
|
810
810
|
* const server = http2.createServer();
|
|
811
811
|
* const expectedWindowSize = 2 ** 20;
|
|
@@ -927,7 +927,7 @@ declare module "http2" {
|
|
|
927
927
|
* This method is only available if `http2session.type` is equal to`http2.constants.NGHTTP2_SESSION_CLIENT`.
|
|
928
928
|
*
|
|
929
929
|
* ```js
|
|
930
|
-
*
|
|
930
|
+
* import http2 from 'node:http2';
|
|
931
931
|
* const clientSession = http2.connect('https://localhost:1234');
|
|
932
932
|
* const {
|
|
933
933
|
* HTTP2_HEADER_PATH,
|
|
@@ -1060,7 +1060,7 @@ declare module "http2" {
|
|
|
1060
1060
|
* Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client.
|
|
1061
1061
|
*
|
|
1062
1062
|
* ```js
|
|
1063
|
-
*
|
|
1063
|
+
* import http2 from 'node:http2';
|
|
1064
1064
|
*
|
|
1065
1065
|
* const server = http2.createServer();
|
|
1066
1066
|
* server.on('session', (session) => {
|
|
@@ -1101,7 +1101,7 @@ declare module "http2" {
|
|
|
1101
1101
|
* authoritative responses.
|
|
1102
1102
|
*
|
|
1103
1103
|
* ```js
|
|
1104
|
-
*
|
|
1104
|
+
* import http2 from 'node:http2';
|
|
1105
1105
|
* const options = getSecureOptionsSomehow();
|
|
1106
1106
|
* const server = http2.createSecureServer(options);
|
|
1107
1107
|
* server.on('stream', (stream) => {
|
|
@@ -1127,7 +1127,7 @@ declare module "http2" {
|
|
|
1127
1127
|
* server using the `http2.createSecureServer()` method:
|
|
1128
1128
|
*
|
|
1129
1129
|
* ```js
|
|
1130
|
-
*
|
|
1130
|
+
* import http2 from 'node:http2';
|
|
1131
1131
|
* const options = getSecureOptionsSomehow();
|
|
1132
1132
|
* options.origins = ['https://example.com', 'https://example.org'];
|
|
1133
1133
|
* const server = http2.createSecureServer(options);
|
|
@@ -1807,7 +1807,7 @@ declare module "http2" {
|
|
|
1807
1807
|
* All other interactions will be routed directly to the socket.
|
|
1808
1808
|
*
|
|
1809
1809
|
* ```js
|
|
1810
|
-
*
|
|
1810
|
+
* import http2 from 'node:http2';
|
|
1811
1811
|
* const server = http2.createServer((req, res) => {
|
|
1812
1812
|
* const ip = req.socket.remoteAddress;
|
|
1813
1813
|
* const port = req.socket.remotePort;
|
|
@@ -2358,7 +2358,7 @@ declare module "http2" {
|
|
|
2358
2358
|
* for use with the `HTTP2-Settings` header field.
|
|
2359
2359
|
*
|
|
2360
2360
|
* ```js
|
|
2361
|
-
*
|
|
2361
|
+
* import http2 from 'node:http2';
|
|
2362
2362
|
*
|
|
2363
2363
|
* const packed = http2.getPackedSettings({ enablePush: false });
|
|
2364
2364
|
*
|
|
@@ -2383,7 +2383,7 @@ declare module "http2" {
|
|
|
2383
2383
|
* with browser clients.
|
|
2384
2384
|
*
|
|
2385
2385
|
* ```js
|
|
2386
|
-
*
|
|
2386
|
+
* import http2 from 'node:http2';
|
|
2387
2387
|
*
|
|
2388
2388
|
* // Create an unencrypted HTTP/2 server.
|
|
2389
2389
|
* // Since there are no browsers known that support
|
|
@@ -2420,8 +2420,8 @@ declare module "http2" {
|
|
|
2420
2420
|
* Returns a `tls.Server` instance that creates and manages `Http2Session` instances.
|
|
2421
2421
|
*
|
|
2422
2422
|
* ```js
|
|
2423
|
-
*
|
|
2424
|
-
*
|
|
2423
|
+
* import http2 from 'node:http2';
|
|
2424
|
+
* import fs from 'node:fs';
|
|
2425
2425
|
*
|
|
2426
2426
|
* const options = {
|
|
2427
2427
|
* key: fs.readFileSync('server-key.pem'),
|
|
@@ -2460,7 +2460,7 @@ declare module "http2" {
|
|
|
2460
2460
|
* Returns a `ClientHttp2Session` instance.
|
|
2461
2461
|
*
|
|
2462
2462
|
* ```js
|
|
2463
|
-
*
|
|
2463
|
+
* import http2 from 'node:http2';
|
|
2464
2464
|
* const client = http2.connect('https://localhost:1234');
|
|
2465
2465
|
*
|
|
2466
2466
|
* // Use the client
|
node v16.18/https.d.ts
CHANGED
|
@@ -260,8 +260,8 @@ declare module "https" {
|
|
|
260
260
|
/**
|
|
261
261
|
* ```js
|
|
262
262
|
* // curl -k https://localhost:8000/
|
|
263
|
-
*
|
|
264
|
-
*
|
|
263
|
+
* import https from 'node:https';
|
|
264
|
+
* import fs from 'node:fs';
|
|
265
265
|
*
|
|
266
266
|
* const options = {
|
|
267
267
|
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
|
@@ -277,8 +277,8 @@ declare module "https" {
|
|
|
277
277
|
* Or
|
|
278
278
|
*
|
|
279
279
|
* ```js
|
|
280
|
-
*
|
|
281
|
-
*
|
|
280
|
+
* import https from 'node:https';
|
|
281
|
+
* import fs from 'node:fs';
|
|
282
282
|
*
|
|
283
283
|
* const options = {
|
|
284
284
|
* pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
|
|
@@ -318,7 +318,7 @@ declare module "https" {
|
|
|
318
318
|
* upload a file with a POST request, then write to the `ClientRequest` object.
|
|
319
319
|
*
|
|
320
320
|
* ```js
|
|
321
|
-
*
|
|
321
|
+
* import https from 'node:https';
|
|
322
322
|
*
|
|
323
323
|
* const options = {
|
|
324
324
|
* hostname: 'encrypted.google.com',
|
|
@@ -391,9 +391,9 @@ declare module "https" {
|
|
|
391
391
|
* Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`):
|
|
392
392
|
*
|
|
393
393
|
* ```js
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
394
|
+
* import tls from 'node:tls';
|
|
395
|
+
* import https from 'node:https';
|
|
396
|
+
* import crypto from 'node:crypto';
|
|
397
397
|
*
|
|
398
398
|
* function sha256(s) {
|
|
399
399
|
* return crypto.createHash('sha256').update(s).digest('base64');
|
|
@@ -501,7 +501,7 @@ declare module "https" {
|
|
|
501
501
|
* string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
|
|
502
502
|
*
|
|
503
503
|
* ```js
|
|
504
|
-
*
|
|
504
|
+
* import https from 'node:https';
|
|
505
505
|
*
|
|
506
506
|
* https.get('https://encrypted.google.com/', (res) => {
|
|
507
507
|
* console.log('statusCode:', res.statusCode);
|
node v16.18/inspector.d.ts
CHANGED
node v16.18/module.d.ts
CHANGED
|
@@ -11,9 +11,9 @@ declare module "module" {
|
|
|
11
11
|
* does not add or remove exported names from the `ES Modules`.
|
|
12
12
|
*
|
|
13
13
|
* ```js
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* import fs from 'node:fs';
|
|
15
|
+
* import assert from 'node:assert';
|
|
16
|
+
* import { syncBuiltinESMExports } from 'node:module';
|
|
17
17
|
*
|
|
18
18
|
* fs.readFile = newAPI;
|
|
19
19
|
*
|
node v16.18/net.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* It can be accessed using:
|
|
9
9
|
*
|
|
10
10
|
* ```js
|
|
11
|
-
*
|
|
11
|
+
* import net from 'node:net';
|
|
12
12
|
* ```
|
|
13
13
|
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/net.js)
|
|
14
14
|
*/
|
|
@@ -717,7 +717,7 @@ declare module "net" {
|
|
|
717
717
|
* on port 8124:
|
|
718
718
|
*
|
|
719
719
|
* ```js
|
|
720
|
-
*
|
|
720
|
+
* import net from 'node:net';
|
|
721
721
|
* const server = net.createServer((c) => {
|
|
722
722
|
* // 'connection' listener.
|
|
723
723
|
* console.log('client connected');
|
node v16.18/os.d.ts
CHANGED
node v16.18/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "16.18.
|
|
3
|
+
"version": "16.18.111",
|
|
4
4
|
"description": "TypeScript definitions for node",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -210,6 +210,6 @@
|
|
|
210
210
|
},
|
|
211
211
|
"scripts": {},
|
|
212
212
|
"dependencies": {},
|
|
213
|
-
"typesPublisherContentHash": "
|
|
213
|
+
"typesPublisherContentHash": "695b15dada90139e7b7288801affaa6ee9bb9602189ec574e64ab886a3061550",
|
|
214
214
|
"typeScriptVersion": "4.8"
|
|
215
215
|
}
|
node v16.18/path.d.ts
CHANGED
node v16.18/perf_hooks.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* * [User Timing](https://www.w3.org/TR/user-timing/)
|
|
10
10
|
*
|
|
11
11
|
* ```js
|
|
12
|
-
*
|
|
12
|
+
* import { PerformanceObserver, performance } from 'node:perf_hooks';
|
|
13
13
|
*
|
|
14
14
|
* const obs = new PerformanceObserver((items) => {
|
|
15
15
|
* console.log(items.getEntries()[0].duration);
|
|
@@ -307,10 +307,10 @@ declare module "perf_hooks" {
|
|
|
307
307
|
* with respect to `performanceEntry.startTime`.
|
|
308
308
|
*
|
|
309
309
|
* ```js
|
|
310
|
-
*
|
|
310
|
+
* import {
|
|
311
311
|
* performance,
|
|
312
312
|
* PerformanceObserver
|
|
313
|
-
* }
|
|
313
|
+
* } from 'node:perf_hooks';
|
|
314
314
|
*
|
|
315
315
|
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
|
316
316
|
* console.log(perfObserverList.getEntries());
|
|
@@ -346,10 +346,10 @@ declare module "perf_hooks" {
|
|
|
346
346
|
* equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to`type`.
|
|
347
347
|
*
|
|
348
348
|
* ```js
|
|
349
|
-
*
|
|
349
|
+
* import {
|
|
350
350
|
* performance,
|
|
351
351
|
* PerformanceObserver
|
|
352
|
-
* }
|
|
352
|
+
* } from 'node:perf_hooks';
|
|
353
353
|
*
|
|
354
354
|
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
|
355
355
|
* console.log(perfObserverList.getEntriesByName('meow'));
|
|
@@ -392,10 +392,10 @@ declare module "perf_hooks" {
|
|
|
392
392
|
* with respect to `performanceEntry.startTime` whose `performanceEntry.entryType`is equal to `type`.
|
|
393
393
|
*
|
|
394
394
|
* ```js
|
|
395
|
-
*
|
|
395
|
+
* import {
|
|
396
396
|
* performance,
|
|
397
397
|
* PerformanceObserver
|
|
398
|
-
* }
|
|
398
|
+
* } from 'node:perf_hooks';
|
|
399
399
|
*
|
|
400
400
|
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
|
401
401
|
* console.log(perfObserverList.getEntriesByType('mark'));
|
|
@@ -438,10 +438,10 @@ declare module "perf_hooks" {
|
|
|
438
438
|
* Subscribes the `PerformanceObserver` instance to notifications of new `PerformanceEntry` instances identified either by `options.entryTypes` or `options.type`:
|
|
439
439
|
*
|
|
440
440
|
* ```js
|
|
441
|
-
*
|
|
441
|
+
* import {
|
|
442
442
|
* performance,
|
|
443
443
|
* PerformanceObserver
|
|
444
|
-
* }
|
|
444
|
+
* } from 'node:perf_hooks';
|
|
445
445
|
*
|
|
446
446
|
* const obs = new PerformanceObserver((list, observer) => {
|
|
447
447
|
* // Called three times synchronously. `list` contains one item.
|
|
@@ -671,7 +671,7 @@ declare module "perf_hooks" {
|
|
|
671
671
|
* detect.
|
|
672
672
|
*
|
|
673
673
|
* ```js
|
|
674
|
-
*
|
|
674
|
+
* import { monitorEventLoopDelay } from 'node:perf_hooks';
|
|
675
675
|
* const h = monitorEventLoopDelay({ resolution: 20 });
|
|
676
676
|
* h.enable();
|
|
677
677
|
* // Do something.
|
|
@@ -713,7 +713,7 @@ declare module "perf_hooks" {
|
|
|
713
713
|
import { performance as _performance } from "perf_hooks";
|
|
714
714
|
global {
|
|
715
715
|
/**
|
|
716
|
-
* `performance` is a global reference for `
|
|
716
|
+
* `performance` is a global reference for `import { performance } from 'node:perf_hooks'`
|
|
717
717
|
* https://nodejs.org/api/globals.html#performance
|
|
718
718
|
* @since v16.0.0
|
|
719
719
|
*/
|
node v16.18/punycode.d.ts
CHANGED
node v16.18/querystring.d.ts
CHANGED
node v16.18/readline.d.ts
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* using:
|
|
4
4
|
*
|
|
5
5
|
* ```js
|
|
6
|
-
*
|
|
6
|
+
* import readline from 'node:readline';
|
|
7
7
|
* ```
|
|
8
8
|
*
|
|
9
9
|
* The following simple example illustrates the basic use of the `readline` module.
|
|
10
10
|
*
|
|
11
11
|
* ```js
|
|
12
|
-
*
|
|
12
|
+
* import readline from 'node:readline';
|
|
13
13
|
*
|
|
14
14
|
* const rl = readline.createInterface({
|
|
15
15
|
* input: process.stdin,
|
|
@@ -176,7 +176,7 @@ declare module "readline" {
|
|
|
176
176
|
* an `AbortController` it will reject with an `AbortError`.
|
|
177
177
|
*
|
|
178
178
|
* ```js
|
|
179
|
-
*
|
|
179
|
+
* import util from 'node:util';
|
|
180
180
|
* const question = util.promisify(rl.question).bind(rl);
|
|
181
181
|
*
|
|
182
182
|
* async function questionExample() {
|
|
@@ -349,7 +349,7 @@ declare module "readline" {
|
|
|
349
349
|
* The `readline.createInterface()` method creates a new `readline.Interface`instance.
|
|
350
350
|
*
|
|
351
351
|
* ```js
|
|
352
|
-
*
|
|
352
|
+
* import readline from 'node:readline';
|
|
353
353
|
* const rl = readline.createInterface({
|
|
354
354
|
* input: process.stdin,
|
|
355
355
|
* output: process.stdout
|
|
@@ -446,7 +446,7 @@ declare module "readline" {
|
|
|
446
446
|
* implement a small command-line interface:
|
|
447
447
|
*
|
|
448
448
|
* ```js
|
|
449
|
-
*
|
|
449
|
+
* import readline from 'node:readline';
|
|
450
450
|
* const rl = readline.createInterface({
|
|
451
451
|
* input: process.stdin,
|
|
452
452
|
* output: process.stdout,
|
|
@@ -478,8 +478,8 @@ declare module "readline" {
|
|
|
478
478
|
* well as a `for await...of` loop:
|
|
479
479
|
*
|
|
480
480
|
* ```js
|
|
481
|
-
*
|
|
482
|
-
*
|
|
481
|
+
* import fs from 'node:fs';
|
|
482
|
+
* import readline from 'node:readline';
|
|
483
483
|
*
|
|
484
484
|
* async function processLineByLine() {
|
|
485
485
|
* const fileStream = fs.createReadStream('input.txt');
|
|
@@ -503,8 +503,8 @@ declare module "readline" {
|
|
|
503
503
|
* Alternatively, one could use the `'line'` event:
|
|
504
504
|
*
|
|
505
505
|
* ```js
|
|
506
|
-
*
|
|
507
|
-
*
|
|
506
|
+
* import fs from 'node:fs';
|
|
507
|
+
* import readline from 'node:readline';
|
|
508
508
|
*
|
|
509
509
|
* const rl = readline.createInterface({
|
|
510
510
|
* input: fs.createReadStream('sample.txt'),
|
|
@@ -519,9 +519,9 @@ declare module "readline" {
|
|
|
519
519
|
* Currently, `for await...of` loop can be a bit slower. If `async` / `await`flow and speed are both essential, a mixed approach can be applied:
|
|
520
520
|
*
|
|
521
521
|
* ```js
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
522
|
+
* import { once } from 'node:events';
|
|
523
|
+
* import { createReadStream } from 'node:fs';
|
|
524
|
+
* import { createInterface } from 'node:readline';
|
|
525
525
|
*
|
|
526
526
|
* (async function processLineByLine() {
|
|
527
527
|
* try {
|
node v16.18/repl.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* It can be accessed using:
|
|
5
5
|
*
|
|
6
6
|
* ```js
|
|
7
|
-
*
|
|
7
|
+
* import repl from 'node:repl';
|
|
8
8
|
* ```
|
|
9
9
|
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/repl.js)
|
|
10
10
|
*/
|
|
@@ -130,7 +130,7 @@ declare module "repl" {
|
|
|
130
130
|
* or directly using the JavaScript `new` keyword.
|
|
131
131
|
*
|
|
132
132
|
* ```js
|
|
133
|
-
*
|
|
133
|
+
* import repl from 'node:repl';
|
|
134
134
|
*
|
|
135
135
|
* const options = { useColors: true };
|
|
136
136
|
*
|
|
@@ -257,7 +257,7 @@ declare module "repl" {
|
|
|
257
257
|
* The following example shows two new commands added to the REPL instance:
|
|
258
258
|
*
|
|
259
259
|
* ```js
|
|
260
|
-
*
|
|
260
|
+
* import repl from 'node:repl';
|
|
261
261
|
*
|
|
262
262
|
* const replServer = repl.start({ prompt: '> ' });
|
|
263
263
|
* replServer.defineCommand('sayhello', {
|
|
@@ -407,7 +407,7 @@ declare module "repl" {
|
|
|
407
407
|
* If `options` is a string, then it specifies the input prompt:
|
|
408
408
|
*
|
|
409
409
|
* ```js
|
|
410
|
-
*
|
|
410
|
+
* import repl from 'node:repl';
|
|
411
411
|
*
|
|
412
412
|
* // a Unix style prompt
|
|
413
413
|
* repl.start('$ ');
|
node v16.18/stream.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* To access the `stream` module:
|
|
10
10
|
*
|
|
11
11
|
* ```js
|
|
12
|
-
*
|
|
12
|
+
* import stream from 'node:stream';
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
15
|
* The `stream` module is useful for creating new types of stream instances. It is
|
|
@@ -293,7 +293,7 @@ declare module "stream" {
|
|
|
293
293
|
* the method does nothing.
|
|
294
294
|
*
|
|
295
295
|
* ```js
|
|
296
|
-
*
|
|
296
|
+
* import fs from 'node:fs';
|
|
297
297
|
* const readable = getReadableStreamSomehow();
|
|
298
298
|
* const writable = fs.createWriteStream('file.txt');
|
|
299
299
|
* // All the data from readable goes into 'file.txt',
|
|
@@ -331,7 +331,7 @@ declare module "stream" {
|
|
|
331
331
|
* // Pull off a header delimited by \n\n.
|
|
332
332
|
* // Use unshift() if we get too much.
|
|
333
333
|
* // Call the callback with (error, header, stream).
|
|
334
|
-
*
|
|
334
|
+
* import { StringDecoder } from 'node:string_decoder';
|
|
335
335
|
* function parseHeader(stream, callback) {
|
|
336
336
|
* stream.on('error', callback);
|
|
337
337
|
* stream.on('readable', onReadable);
|
|
@@ -389,8 +389,8 @@ declare module "stream" {
|
|
|
389
389
|
* libraries.
|
|
390
390
|
*
|
|
391
391
|
* ```js
|
|
392
|
-
*
|
|
393
|
-
*
|
|
392
|
+
* import { OldReader } from './old-api-module.js';
|
|
393
|
+
* import { Readable } from 'node:stream';
|
|
394
394
|
* const oreader = new OldReader();
|
|
395
395
|
* const myReader = new Readable().wrap(oreader);
|
|
396
396
|
*
|
|
@@ -669,7 +669,7 @@ declare module "stream" {
|
|
|
669
669
|
*
|
|
670
670
|
* ```js
|
|
671
671
|
* // Write 'hello, ' and then end with 'world!'.
|
|
672
|
-
*
|
|
672
|
+
* import fs from 'node:fs';
|
|
673
673
|
* const file = fs.createWriteStream('example.txt');
|
|
674
674
|
* file.write('hello, ');
|
|
675
675
|
* file.end('world!');
|
|
@@ -1062,7 +1062,7 @@ declare module "stream" {
|
|
|
1062
1062
|
* Calling `abort` on the `AbortController` corresponding to the passed`AbortSignal` will behave the same way as calling `.destroy(new AbortError())`on the stream.
|
|
1063
1063
|
*
|
|
1064
1064
|
* ```js
|
|
1065
|
-
*
|
|
1065
|
+
* import fs from 'node:fs';
|
|
1066
1066
|
*
|
|
1067
1067
|
* const controller = new AbortController();
|
|
1068
1068
|
* const read = addAbortSignal(
|
|
@@ -1111,7 +1111,7 @@ declare module "stream" {
|
|
|
1111
1111
|
* or has experienced an error or a premature close event.
|
|
1112
1112
|
*
|
|
1113
1113
|
* ```js
|
|
1114
|
-
*
|
|
1114
|
+
* import { finished } from 'node:stream';
|
|
1115
1115
|
*
|
|
1116
1116
|
* const rs = fs.createReadStream('archive.tar');
|
|
1117
1117
|
*
|
|
@@ -1132,7 +1132,7 @@ declare module "stream" {
|
|
|
1132
1132
|
* The `finished` API provides promise version:
|
|
1133
1133
|
*
|
|
1134
1134
|
* ```js
|
|
1135
|
-
*
|
|
1135
|
+
* import { finished } from 'node:stream/promises';
|
|
1136
1136
|
*
|
|
1137
1137
|
* const rs = fs.createReadStream('archive.tar');
|
|
1138
1138
|
*
|
|
@@ -1208,9 +1208,9 @@ declare module "stream" {
|
|
|
1208
1208
|
* properly cleaning up and provide a callback when the pipeline is complete.
|
|
1209
1209
|
*
|
|
1210
1210
|
* ```js
|
|
1211
|
-
*
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1211
|
+
* import { pipeline } from 'node:stream';
|
|
1212
|
+
* import fs from 'node:fs';
|
|
1213
|
+
* import zlib from 'node:zlib';
|
|
1214
1214
|
*
|
|
1215
1215
|
* // Use the pipeline API to easily pipe a series of streams
|
|
1216
1216
|
* // together and get notified when the pipeline is fully done.
|
|
@@ -1236,7 +1236,7 @@ declare module "stream" {
|
|
|
1236
1236
|
* an`AbortError`.
|
|
1237
1237
|
*
|
|
1238
1238
|
* ```js
|
|
1239
|
-
*
|
|
1239
|
+
* import { pipeline } from 'node:stream/promises';
|
|
1240
1240
|
*
|
|
1241
1241
|
* async function run() {
|
|
1242
1242
|
* await pipeline(
|
|
@@ -1254,7 +1254,7 @@ declare module "stream" {
|
|
|
1254
1254
|
* as the last argument:
|
|
1255
1255
|
*
|
|
1256
1256
|
* ```js
|
|
1257
|
-
*
|
|
1257
|
+
* import { pipeline } from 'node:stream/promises';
|
|
1258
1258
|
*
|
|
1259
1259
|
* async function run() {
|
|
1260
1260
|
* const ac = new AbortController();
|
|
@@ -1275,8 +1275,8 @@ declare module "stream" {
|
|
|
1275
1275
|
* The `pipeline` API also supports async generators:
|
|
1276
1276
|
*
|
|
1277
1277
|
* ```js
|
|
1278
|
-
*
|
|
1279
|
-
*
|
|
1278
|
+
* import { pipeline } from 'node:stream/promises';
|
|
1279
|
+
* import fs from 'node:fs';
|
|
1280
1280
|
*
|
|
1281
1281
|
* async function run() {
|
|
1282
1282
|
* await pipeline(
|
|
@@ -1300,8 +1300,8 @@ declare module "stream" {
|
|
|
1300
1300
|
* pipeline (i.e. first argument) or the pipeline will never complete.
|
|
1301
1301
|
*
|
|
1302
1302
|
* ```js
|
|
1303
|
-
*
|
|
1304
|
-
*
|
|
1303
|
+
* import { pipeline } from 'node:stream/promises';
|
|
1304
|
+
* import fs from 'node:fs';
|
|
1305
1305
|
*
|
|
1306
1306
|
* async function run() {
|
|
1307
1307
|
* await pipeline(
|