@types/node 18.11.5 → 20.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node/README.md +2 -2
- node/assert.d.ts +86 -75
- node/async_hooks.d.ts +66 -37
- node/buffer.d.ts +193 -100
- node/child_process.d.ts +82 -56
- node/cluster.d.ts +12 -12
- node/console.d.ts +5 -5
- node/crypto.d.ts +233 -235
- node/dgram.d.ts +15 -15
- node/diagnostics_channel.d.ts +59 -21
- node/dns/promises.d.ts +50 -6
- node/dns.d.ts +26 -17
- node/domain.d.ts +4 -4
- node/events.d.ts +111 -65
- node/fs/promises.d.ts +99 -47
- node/fs.d.ts +244 -73
- node/globals.d.ts +6 -3
- node/http.d.ts +265 -148
- node/http2.d.ts +42 -47
- node/https.d.ts +53 -153
- node/index.d.ts +2 -1
- node/inspector.d.ts +10 -3
- node/module.d.ts +6 -4
- node/net.d.ts +32 -15
- node/os.d.ts +27 -16
- node/package.json +9 -4
- node/path.d.ts +4 -4
- node/perf_hooks.d.ts +28 -15
- node/process.d.ts +49 -46
- node/punycode.d.ts +1 -1
- node/querystring.d.ts +5 -5
- node/readline/promises.d.ts +65 -63
- node/readline.d.ts +32 -159
- node/repl.d.ts +20 -20
- node/stream/consumers.d.ts +1 -1
- node/stream.d.ts +950 -869
- node/string_decoder.d.ts +6 -6
- node/test.d.ts +877 -139
- node/timers/promises.d.ts +26 -1
- node/timers.d.ts +125 -4
- node/tls.d.ts +120 -29
- node/trace_events.d.ts +20 -9
- node/ts4.8/assert.d.ts +86 -75
- node/ts4.8/async_hooks.d.ts +66 -37
- node/ts4.8/buffer.d.ts +193 -101
- node/ts4.8/child_process.d.ts +82 -56
- node/ts4.8/cluster.d.ts +12 -12
- node/ts4.8/console.d.ts +5 -5
- node/ts4.8/crypto.d.ts +230 -233
- node/ts4.8/dgram.d.ts +15 -15
- node/ts4.8/diagnostics_channel.d.ts +59 -21
- node/ts4.8/dns/promises.d.ts +50 -6
- node/ts4.8/dns.d.ts +26 -17
- node/ts4.8/domain.d.ts +4 -4
- node/ts4.8/events.d.ts +111 -65
- node/ts4.8/fs/promises.d.ts +97 -46
- node/ts4.8/fs.d.ts +244 -73
- node/ts4.8/globals.d.ts +21 -12
- node/ts4.8/http.d.ts +265 -148
- node/ts4.8/http2.d.ts +42 -47
- node/ts4.8/https.d.ts +53 -153
- node/ts4.8/inspector.d.ts +10 -3
- node/ts4.8/module.d.ts +6 -4
- node/ts4.8/net.d.ts +33 -16
- node/ts4.8/os.d.ts +27 -16
- node/ts4.8/path.d.ts +4 -4
- node/ts4.8/perf_hooks.d.ts +28 -15
- node/ts4.8/process.d.ts +49 -46
- node/ts4.8/punycode.d.ts +1 -1
- node/ts4.8/querystring.d.ts +5 -5
- node/ts4.8/readline/promises.d.ts +65 -63
- node/ts4.8/readline.d.ts +32 -159
- node/ts4.8/repl.d.ts +20 -20
- node/ts4.8/stream/consumers.d.ts +1 -1
- node/ts4.8/stream.d.ts +192 -140
- node/ts4.8/string_decoder.d.ts +6 -6
- node/ts4.8/test.d.ts +877 -139
- node/ts4.8/timers/promises.d.ts +26 -1
- node/ts4.8/timers.d.ts +125 -4
- node/ts4.8/tls.d.ts +120 -29
- node/ts4.8/trace_events.d.ts +20 -9
- node/ts4.8/tty.d.ts +4 -5
- node/ts4.8/url.d.ts +46 -42
- node/ts4.8/util.d.ts +325 -123
- node/ts4.8/v8.d.ts +253 -14
- node/ts4.8/vm.d.ts +417 -32
- node/ts4.8/wasi.d.ts +13 -19
- node/ts4.8/worker_threads.d.ts +38 -34
- node/ts4.8/zlib.d.ts +11 -11
- node/tty.d.ts +4 -5
- node/url.d.ts +46 -42
- node/util.d.ts +325 -123
- node/v8.d.ts +253 -14
- node/vm.d.ts +417 -32
- node/wasi.d.ts +13 -19
- node/worker_threads.d.ts +38 -34
- node/zlib.d.ts +11 -11
node/ts4.8/wasi.d.ts
CHANGED
|
@@ -3,26 +3,23 @@
|
|
|
3
3
|
* underlying operating system via a collection of POSIX-like functions.
|
|
4
4
|
*
|
|
5
5
|
* ```js
|
|
6
|
-
* import { readFile } from 'fs/promises';
|
|
6
|
+
* import { readFile } from 'node:fs/promises';
|
|
7
7
|
* import { WASI } from 'wasi';
|
|
8
|
-
* import { argv, env } from 'process';
|
|
8
|
+
* import { argv, env } from 'node:process';
|
|
9
9
|
*
|
|
10
10
|
* const wasi = new WASI({
|
|
11
|
+
* version: 'preview1',
|
|
11
12
|
* args: argv,
|
|
12
13
|
* env,
|
|
13
14
|
* preopens: {
|
|
14
|
-
* '/sandbox': '/some/real/path/that/wasm/can/access'
|
|
15
|
-
* }
|
|
15
|
+
* '/sandbox': '/some/real/path/that/wasm/can/access',
|
|
16
|
+
* },
|
|
16
17
|
* });
|
|
17
18
|
*
|
|
18
|
-
* // Some WASI binaries require:
|
|
19
|
-
* // const importObject = { wasi_unstable: wasi.wasiImport };
|
|
20
|
-
* const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
|
|
21
|
-
*
|
|
22
19
|
* const wasm = await WebAssembly.compile(
|
|
23
|
-
* await readFile(new URL('./demo.wasm', import.meta.url))
|
|
20
|
+
* await readFile(new URL('./demo.wasm', import.meta.url)),
|
|
24
21
|
* );
|
|
25
|
-
* const instance = await WebAssembly.instantiate(wasm,
|
|
22
|
+
* const instance = await WebAssembly.instantiate(wasm, wasi.getImportObject());
|
|
26
23
|
*
|
|
27
24
|
* wasi.start(instance);
|
|
28
25
|
* ```
|
|
@@ -64,11 +61,8 @@
|
|
|
64
61
|
* ```console
|
|
65
62
|
* $ wat2wasm demo.wat
|
|
66
63
|
* ```
|
|
67
|
-
*
|
|
68
|
-
* The `--experimental-wasi-unstable-preview1` CLI argument is needed for this
|
|
69
|
-
* example to run.
|
|
70
64
|
* @experimental
|
|
71
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
65
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/wasi.js)
|
|
72
66
|
*/
|
|
73
67
|
declare module 'wasi' {
|
|
74
68
|
interface WASIOptions {
|
|
@@ -91,11 +85,11 @@ declare module 'wasi' {
|
|
|
91
85
|
*/
|
|
92
86
|
preopens?: NodeJS.Dict<string> | undefined;
|
|
93
87
|
/**
|
|
94
|
-
* By default, WASI applications
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* @default
|
|
88
|
+
* By default, when WASI applications call `__wasi_proc_exit()`
|
|
89
|
+
* `wasi.start()` will return with the exit code specified rather than terminatng the process.
|
|
90
|
+
* Setting this option to `false` will cause the Node.js process to exit with
|
|
91
|
+
* the specified exit code instead.
|
|
92
|
+
* @default true
|
|
99
93
|
*/
|
|
100
94
|
returnOnExit?: boolean | undefined;
|
|
101
95
|
/**
|
node/ts4.8/worker_threads.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `worker_threads` module enables the use of threads that execute
|
|
3
|
-
* in parallel. To access it:
|
|
2
|
+
* The `node:worker_threads` module enables the use of threads that execute
|
|
3
|
+
* JavaScript in parallel. To access it:
|
|
4
4
|
*
|
|
5
5
|
* ```js
|
|
6
|
-
* const worker = require('worker_threads');
|
|
6
|
+
* const worker = require('node:worker_threads');
|
|
7
7
|
* ```
|
|
8
8
|
*
|
|
9
9
|
* Workers (threads) are useful for performing CPU-intensive JavaScript operations.
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
*
|
|
16
16
|
* ```js
|
|
17
17
|
* const {
|
|
18
|
-
* Worker, isMainThread, parentPort, workerData
|
|
19
|
-
* } = require('worker_threads');
|
|
18
|
+
* Worker, isMainThread, parentPort, workerData,
|
|
19
|
+
* } = require('node:worker_threads');
|
|
20
20
|
*
|
|
21
21
|
* if (isMainThread) {
|
|
22
22
|
* module.exports = function parseJSAsync(script) {
|
|
23
23
|
* return new Promise((resolve, reject) => {
|
|
24
24
|
* const worker = new Worker(__filename, {
|
|
25
|
-
* workerData: script
|
|
25
|
+
* workerData: script,
|
|
26
26
|
* });
|
|
27
27
|
* worker.on('message', resolve);
|
|
28
28
|
* worker.on('error', reject);
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
*
|
|
50
50
|
* Worker threads inherit non-process-specific options by default. Refer to `Worker constructor options` to know how to customize worker thread options,
|
|
51
51
|
* specifically `argv` and `execArgv` options.
|
|
52
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
52
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/worker_threads.js)
|
|
53
53
|
*/
|
|
54
54
|
declare module 'worker_threads' {
|
|
55
55
|
import { Blob } from 'node:buffer';
|
|
@@ -72,7 +72,7 @@ declare module 'worker_threads' {
|
|
|
72
72
|
* The `MessageChannel` has no methods of its own. `new MessageChannel()`yields an object with `port1` and `port2` properties, which refer to linked `MessagePort` instances.
|
|
73
73
|
*
|
|
74
74
|
* ```js
|
|
75
|
-
* const { MessageChannel } = require('worker_threads');
|
|
75
|
+
* const { MessageChannel } = require('node:worker_threads');
|
|
76
76
|
*
|
|
77
77
|
* const { port1, port2 } = new MessageChannel();
|
|
78
78
|
* port1.on('message', (message) => console.log('received', message));
|
|
@@ -121,7 +121,7 @@ declare module 'worker_threads' {
|
|
|
121
121
|
* * `value` may not contain native (C++-backed) objects other than:
|
|
122
122
|
*
|
|
123
123
|
* ```js
|
|
124
|
-
* const { MessageChannel } = require('worker_threads');
|
|
124
|
+
* const { MessageChannel } = require('node:worker_threads');
|
|
125
125
|
* const { port1, port2 } = new MessageChannel();
|
|
126
126
|
*
|
|
127
127
|
* port1.on('message', (message) => console.log(message));
|
|
@@ -132,7 +132,7 @@ declare module 'worker_threads' {
|
|
|
132
132
|
* port2.postMessage(circularData);
|
|
133
133
|
* ```
|
|
134
134
|
*
|
|
135
|
-
* `transferList` may be a list of [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), `MessagePort
|
|
135
|
+
* `transferList` may be a list of [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), `MessagePort`, and `FileHandle` objects.
|
|
136
136
|
* After transferring, they are not usable on the sending side of the channel
|
|
137
137
|
* anymore (even if they are not contained in `value`). Unlike with `child processes`, transferring handles such as network sockets is currently
|
|
138
138
|
* not supported.
|
|
@@ -143,7 +143,7 @@ declare module 'worker_threads' {
|
|
|
143
143
|
* `value` may still contain `ArrayBuffer` instances that are not in`transferList`; in that case, the underlying memory is copied rather than moved.
|
|
144
144
|
*
|
|
145
145
|
* ```js
|
|
146
|
-
* const { MessageChannel } = require('worker_threads');
|
|
146
|
+
* const { MessageChannel } = require('node:worker_threads');
|
|
147
147
|
* const { port1, port2 } = new MessageChannel();
|
|
148
148
|
*
|
|
149
149
|
* port1.on('message', (message) => console.log(message));
|
|
@@ -170,7 +170,7 @@ declare module 'worker_threads' {
|
|
|
170
170
|
* posting without having side effects.
|
|
171
171
|
*
|
|
172
172
|
* For more information on the serialization and deserialization mechanisms
|
|
173
|
-
* behind this API, see the `serialization API of the v8 module`.
|
|
173
|
+
* behind this API, see the `serialization API of the node:v8 module`.
|
|
174
174
|
* @since v10.5.0
|
|
175
175
|
*/
|
|
176
176
|
postMessage(value: any, transferList?: ReadonlyArray<TransferListItem>): void;
|
|
@@ -262,6 +262,12 @@ declare module 'worker_threads' {
|
|
|
262
262
|
* @default true
|
|
263
263
|
*/
|
|
264
264
|
trackUnmanagedFds?: boolean | undefined;
|
|
265
|
+
/**
|
|
266
|
+
* An optional `name` to be appended to the worker title
|
|
267
|
+
* for debuggin/identification purposes, making the final title as
|
|
268
|
+
* `[worker ${id}] ${name}`.
|
|
269
|
+
*/
|
|
270
|
+
name?: string | undefined;
|
|
265
271
|
}
|
|
266
272
|
interface ResourceLimits {
|
|
267
273
|
/**
|
|
@@ -288,9 +294,9 @@ declare module 'worker_threads' {
|
|
|
288
294
|
*
|
|
289
295
|
* Notable differences inside a Worker environment are:
|
|
290
296
|
*
|
|
291
|
-
* * The `process.stdin`, `process.stdout
|
|
292
|
-
* * The `require('worker_threads').isMainThread` property is set to `false`.
|
|
293
|
-
* * The `require('worker_threads').parentPort` message port is available.
|
|
297
|
+
* * The `process.stdin`, `process.stdout`, and `process.stderr` streams may be redirected by the parent thread.
|
|
298
|
+
* * The `require('node:worker_threads').isMainThread` property is set to `false`.
|
|
299
|
+
* * The `require('node:worker_threads').parentPort` message port is available.
|
|
294
300
|
* * `process.exit()` does not stop the whole program, just the single thread,
|
|
295
301
|
* and `process.abort()` is not available.
|
|
296
302
|
* * `process.chdir()` and `process` methods that set group or user ids
|
|
@@ -307,11 +313,11 @@ declare module 'worker_threads' {
|
|
|
307
313
|
*
|
|
308
314
|
* Creating `Worker` instances inside of other `Worker`s is possible.
|
|
309
315
|
*
|
|
310
|
-
* Like [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) and the `cluster module`, two-way communication
|
|
311
|
-
* achieved through inter-thread message passing. Internally, a `Worker` has
|
|
312
|
-
* built-in pair of `MessagePort` s that are already associated with each
|
|
313
|
-
* when the `Worker` is created. While the `MessagePort` object on the parent
|
|
314
|
-
* is not directly exposed, its functionalities are exposed through `worker.postMessage()` and the `worker.on('message')` event
|
|
316
|
+
* Like [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) and the `node:cluster module`, two-way communication
|
|
317
|
+
* can be achieved through inter-thread message passing. Internally, a `Worker` has
|
|
318
|
+
* a built-in pair of `MessagePort` s that are already associated with each
|
|
319
|
+
* other when the `Worker` is created. While the `MessagePort` object on the parent
|
|
320
|
+
* side is not directly exposed, its functionalities are exposed through `worker.postMessage()` and the `worker.on('message')` event
|
|
315
321
|
* on the `Worker` object for the parent thread.
|
|
316
322
|
*
|
|
317
323
|
* To create custom messaging channels (which is encouraged over using the default
|
|
@@ -324,10 +330,10 @@ declare module 'worker_threads' {
|
|
|
324
330
|
* the thread barrier.
|
|
325
331
|
*
|
|
326
332
|
* ```js
|
|
327
|
-
* const assert = require('assert');
|
|
333
|
+
* const assert = require('node:assert');
|
|
328
334
|
* const {
|
|
329
|
-
* Worker, MessageChannel, MessagePort, isMainThread, parentPort
|
|
330
|
-
* } = require('worker_threads');
|
|
335
|
+
* Worker, MessageChannel, MessagePort, isMainThread, parentPort,
|
|
336
|
+
* } = require('node:worker_threads');
|
|
331
337
|
* if (isMainThread) {
|
|
332
338
|
* const worker = new Worker(__filename);
|
|
333
339
|
* const subChannel = new MessageChannel();
|
|
@@ -367,7 +373,7 @@ declare module 'worker_threads' {
|
|
|
367
373
|
readonly stderr: Readable;
|
|
368
374
|
/**
|
|
369
375
|
* An integer identifier for the referenced thread. Inside the worker thread,
|
|
370
|
-
* it is available as `require('worker_threads').threadId`.
|
|
376
|
+
* it is available as `require('node:worker_threads').threadId`.
|
|
371
377
|
* This value is unique for each `Worker` instance inside a single process.
|
|
372
378
|
* @since v10.5.0
|
|
373
379
|
*/
|
|
@@ -394,7 +400,7 @@ declare module 'worker_threads' {
|
|
|
394
400
|
*/
|
|
395
401
|
constructor(filename: string | URL, options?: WorkerOptions);
|
|
396
402
|
/**
|
|
397
|
-
* Send a message to the worker that is received via `require('worker_threads').parentPort.on('message')`.
|
|
403
|
+
* Send a message to the worker that is received via `require('node:worker_threads').parentPort.on('message')`.
|
|
398
404
|
* See `port.postMessage()` for more details.
|
|
399
405
|
* @since v10.5.0
|
|
400
406
|
*/
|
|
@@ -488,8 +494,8 @@ declare module 'worker_threads' {
|
|
|
488
494
|
* const {
|
|
489
495
|
* isMainThread,
|
|
490
496
|
* BroadcastChannel,
|
|
491
|
-
* Worker
|
|
492
|
-
* } = require('worker_threads');
|
|
497
|
+
* Worker,
|
|
498
|
+
* } = require('node:worker_threads');
|
|
493
499
|
*
|
|
494
500
|
* const bc = new BroadcastChannel('hello');
|
|
495
501
|
*
|
|
@@ -543,7 +549,7 @@ declare module 'worker_threads' {
|
|
|
543
549
|
* This operation cannot be undone.
|
|
544
550
|
*
|
|
545
551
|
* ```js
|
|
546
|
-
* const { MessageChannel, markAsUntransferable } = require('worker_threads');
|
|
552
|
+
* const { MessageChannel, markAsUntransferable } = require('node:worker_threads');
|
|
547
553
|
*
|
|
548
554
|
* const pooledBuffer = new ArrayBuffer(8);
|
|
549
555
|
* const typedArray1 = new Uint8Array(pooledBuffer);
|
|
@@ -585,10 +591,10 @@ declare module 'worker_threads' {
|
|
|
585
591
|
function moveMessagePortToContext(port: MessagePort, contextifiedSandbox: Context): MessagePort;
|
|
586
592
|
/**
|
|
587
593
|
* Receive a single message from a given `MessagePort`. If no message is available,`undefined` is returned, otherwise an object with a single `message` property
|
|
588
|
-
* that contains the message payload, corresponding to the oldest message in the`MessagePort
|
|
594
|
+
* that contains the message payload, corresponding to the oldest message in the`MessagePort`'s queue.
|
|
589
595
|
*
|
|
590
596
|
* ```js
|
|
591
|
-
* const { MessageChannel, receiveMessageOnPort } = require('worker_threads');
|
|
597
|
+
* const { MessageChannel, receiveMessageOnPort } = require('node:worker_threads');
|
|
592
598
|
* const { port1, port2 } = new MessageChannel();
|
|
593
599
|
* port1.postMessage({ hello: 'world' });
|
|
594
600
|
*
|
|
@@ -619,7 +625,7 @@ declare module 'worker_threads' {
|
|
|
619
625
|
* isMainThread,
|
|
620
626
|
* setEnvironmentData,
|
|
621
627
|
* getEnvironmentData,
|
|
622
|
-
* } = require('worker_threads');
|
|
628
|
+
* } = require('node:worker_threads');
|
|
623
629
|
*
|
|
624
630
|
* if (isMainThread) {
|
|
625
631
|
* setEnvironmentData('Hello', 'World!');
|
|
@@ -658,7 +664,6 @@ declare module 'worker_threads' {
|
|
|
658
664
|
}
|
|
659
665
|
? T
|
|
660
666
|
: typeof _BroadcastChannel;
|
|
661
|
-
|
|
662
667
|
/**
|
|
663
668
|
* `MessageChannel` class is a global reference for `require('worker_threads').MessageChannel`
|
|
664
669
|
* https://nodejs.org/api/globals.html#messagechannel
|
|
@@ -670,13 +675,12 @@ declare module 'worker_threads' {
|
|
|
670
675
|
}
|
|
671
676
|
? T
|
|
672
677
|
: typeof _MessageChannel;
|
|
673
|
-
|
|
674
678
|
/**
|
|
675
679
|
* `MessagePort` class is a global reference for `require('worker_threads').MessagePort`
|
|
676
680
|
* https://nodejs.org/api/globals.html#messageport
|
|
677
681
|
* @since v15.0.0
|
|
678
682
|
*/
|
|
679
|
-
|
|
683
|
+
var MessagePort: typeof globalThis extends {
|
|
680
684
|
onmessage: any;
|
|
681
685
|
MessagePort: infer T;
|
|
682
686
|
}
|
node/ts4.8/zlib.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `zlib` module provides compression functionality implemented using
|
|
3
|
-
* Deflate/Inflate, and Brotli.
|
|
2
|
+
* The `node:zlib` module provides compression functionality implemented using
|
|
3
|
+
* Gzip, Deflate/Inflate, and Brotli.
|
|
4
4
|
*
|
|
5
5
|
* To access it:
|
|
6
6
|
*
|
|
7
7
|
* ```js
|
|
8
|
-
* const zlib = require('zlib');
|
|
8
|
+
* const zlib = require('node:zlib');
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
11
|
* Compression and decompression are built around the Node.js `Streams API`.
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
* stream:
|
|
16
16
|
*
|
|
17
17
|
* ```js
|
|
18
|
-
* const { createGzip } = require('zlib');
|
|
19
|
-
* const { pipeline } = require('stream');
|
|
18
|
+
* const { createGzip } = require('node:zlib');
|
|
19
|
+
* const { pipeline } = require('node:stream');
|
|
20
20
|
* const {
|
|
21
21
|
* createReadStream,
|
|
22
|
-
* createWriteStream
|
|
23
|
-
* } = require('fs');
|
|
22
|
+
* createWriteStream,
|
|
23
|
+
* } = require('node:fs');
|
|
24
24
|
*
|
|
25
25
|
* const gzip = createGzip();
|
|
26
26
|
* const source = createReadStream('input.txt');
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
*
|
|
36
36
|
* // Or, Promisified
|
|
37
37
|
*
|
|
38
|
-
* const { promisify } = require('util');
|
|
38
|
+
* const { promisify } = require('node:util');
|
|
39
39
|
* const pipe = promisify(pipeline);
|
|
40
40
|
*
|
|
41
41
|
* async function do_gzip(input, output) {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
* It is also possible to compress or decompress data in a single step:
|
|
56
56
|
*
|
|
57
57
|
* ```js
|
|
58
|
-
* const { deflate, unzip } = require('zlib');
|
|
58
|
+
* const { deflate, unzip } = require('node:zlib');
|
|
59
59
|
*
|
|
60
60
|
* const input = '.................................';
|
|
61
61
|
* deflate(input, (err, buffer) => {
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
*
|
|
78
78
|
* // Or, Promisified
|
|
79
79
|
*
|
|
80
|
-
* const { promisify } = require('util');
|
|
80
|
+
* const { promisify } = require('node:util');
|
|
81
81
|
* const do_unzip = promisify(unzip);
|
|
82
82
|
*
|
|
83
83
|
* do_unzip(buffer)
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
* });
|
|
89
89
|
* ```
|
|
90
90
|
* @since v0.5.8
|
|
91
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
91
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/zlib.js)
|
|
92
92
|
*/
|
|
93
93
|
declare module 'zlib' {
|
|
94
94
|
import * as stream from 'node:stream';
|
node/tty.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `tty` module provides the `tty.ReadStream` and `tty.WriteStream`
|
|
3
|
-
*
|
|
4
|
-
* However, it can be accessed using:
|
|
2
|
+
* The `node:tty` module provides the `tty.ReadStream` and `tty.WriteStream`classes. In most cases, it will not be necessary or possible to use this module
|
|
3
|
+
* directly. However, it can be accessed using:
|
|
5
4
|
*
|
|
6
5
|
* ```js
|
|
7
|
-
* const tty = require('tty');
|
|
6
|
+
* const tty = require('node:tty');
|
|
8
7
|
* ```
|
|
9
8
|
*
|
|
10
9
|
* When Node.js detects that it is being run with a text terminal ("TTY")
|
|
@@ -22,7 +21,7 @@
|
|
|
22
21
|
*
|
|
23
22
|
* In most cases, there should be little to no reason for an application to
|
|
24
23
|
* manually create instances of the `tty.ReadStream` and `tty.WriteStream`classes.
|
|
25
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
24
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/tty.js)
|
|
26
25
|
*/
|
|
27
26
|
declare module 'tty' {
|
|
28
27
|
import * as net from 'node:net';
|
node/url.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `url` module provides utilities for URL resolution and parsing. It can
|
|
3
|
-
* accessed using:
|
|
2
|
+
* The `node:url` module provides utilities for URL resolution and parsing. It can
|
|
3
|
+
* be accessed using:
|
|
4
4
|
*
|
|
5
5
|
* ```js
|
|
6
|
-
* import url from 'url';
|
|
6
|
+
* import url from 'node:url';
|
|
7
7
|
* ```
|
|
8
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
8
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/url.js)
|
|
9
9
|
*/
|
|
10
10
|
declare module 'url' {
|
|
11
11
|
import { Blob as NodeBlob } from 'node:buffer';
|
|
@@ -54,17 +54,11 @@ declare module 'url' {
|
|
|
54
54
|
*
|
|
55
55
|
* A `URIError` is thrown if the `auth` property is present but cannot be decoded.
|
|
56
56
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* issues can be introduced. Specifically, issues with [host name spoofing](https://hackerone.com/reports/678487) and
|
|
61
|
-
* incorrect handling of usernames and passwords have been identified.
|
|
62
|
-
*
|
|
63
|
-
* Deprecation of this API has been shelved for now primarily due to the the
|
|
64
|
-
* inability of the [WHATWG API to parse relative URLs](https://github.com/nodejs/node/issues/12682#issuecomment-1154492373).
|
|
65
|
-
* [Discussions are ongoing](https://github.com/whatwg/url/issues/531) for the best way to resolve this.
|
|
66
|
-
*
|
|
57
|
+
* `url.parse()` uses a lenient, non-standard algorithm for parsing URL
|
|
58
|
+
* strings. It is prone to security issues such as [host name spoofing](https://hackerone.com/reports/678487) and incorrect handling of usernames and passwords. Do not use with untrusted
|
|
59
|
+
* input. CVEs are not issued for `url.parse()` vulnerabilities. Use the `WHATWG URL` API instead.
|
|
67
60
|
* @since v0.1.25
|
|
61
|
+
* @deprecated Use the WHATWG URL API instead.
|
|
68
62
|
* @param urlString The URL string to parse.
|
|
69
63
|
* @param [parseQueryString=false] If `true`, the `query` property will always be set to an object returned by the {@link querystring} module's `parse()` method. If `false`, the `query` property
|
|
70
64
|
* on the returned URL object will be an unparsed, undecoded string.
|
|
@@ -79,15 +73,15 @@ declare module 'url' {
|
|
|
79
73
|
* The `url.format()` method returns a formatted URL string derived from`urlObject`.
|
|
80
74
|
*
|
|
81
75
|
* ```js
|
|
82
|
-
* const url = require('url');
|
|
76
|
+
* const url = require('node:url');
|
|
83
77
|
* url.format({
|
|
84
78
|
* protocol: 'https',
|
|
85
79
|
* hostname: 'example.com',
|
|
86
80
|
* pathname: '/some/path',
|
|
87
81
|
* query: {
|
|
88
82
|
* page: 1,
|
|
89
|
-
* format: 'json'
|
|
90
|
-
* }
|
|
83
|
+
* format: 'json',
|
|
84
|
+
* },
|
|
91
85
|
* });
|
|
92
86
|
*
|
|
93
87
|
* // => 'https://example.com/some/path?page=1&format=json'
|
|
@@ -135,7 +129,7 @@ declare module 'url' {
|
|
|
135
129
|
* string, an `Error` is thrown.
|
|
136
130
|
* * `result` is returned.
|
|
137
131
|
* @since v0.1.25
|
|
138
|
-
* @
|
|
132
|
+
* @legacy Use the WHATWG URL API instead.
|
|
139
133
|
* @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise). If a string, it is converted to an object by passing it to `url.parse()`.
|
|
140
134
|
*/
|
|
141
135
|
function format(urlObject: URL, options?: URLFormatOptions): string;
|
|
@@ -199,7 +193,7 @@ declare module 'url' {
|
|
|
199
193
|
* string, an `Error` is thrown.
|
|
200
194
|
* * `result` is returned.
|
|
201
195
|
* @since v0.1.25
|
|
202
|
-
* @
|
|
196
|
+
* @legacy Use the WHATWG URL API instead.
|
|
203
197
|
* @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise). If a string, it is converted to an object by passing it to `url.parse()`.
|
|
204
198
|
*/
|
|
205
199
|
function format(urlObject: UrlObject | string): string;
|
|
@@ -208,7 +202,7 @@ declare module 'url' {
|
|
|
208
202
|
* manner similar to that of a web browser resolving an anchor tag.
|
|
209
203
|
*
|
|
210
204
|
* ```js
|
|
211
|
-
* const url = require('url');
|
|
205
|
+
* const url = require('node:url');
|
|
212
206
|
* url.resolve('/one/two/three', 'four'); // '/one/two/four'
|
|
213
207
|
* url.resolve('http://example.com/', '/one'); // 'http://example.com/one'
|
|
214
208
|
* url.resolve('http://example.com/one', '/two'); // 'http://example.com/two'
|
|
@@ -232,7 +226,7 @@ declare module 'url' {
|
|
|
232
226
|
* resolve('http://example.com/one', '/two'); // 'http://example.com/two'
|
|
233
227
|
* ```
|
|
234
228
|
* @since v0.1.25
|
|
235
|
-
* @
|
|
229
|
+
* @legacy Use the WHATWG URL API instead.
|
|
236
230
|
* @param from The base URL to use if `to` is a relative URL.
|
|
237
231
|
* @param to The target URL to resolve.
|
|
238
232
|
*/
|
|
@@ -243,10 +237,8 @@ declare module 'url' {
|
|
|
243
237
|
*
|
|
244
238
|
* It performs the inverse operation to {@link domainToUnicode}.
|
|
245
239
|
*
|
|
246
|
-
* This feature is only available if the `node` executable was compiled with `ICU` enabled. If not, the domain names are passed through unchanged.
|
|
247
|
-
*
|
|
248
240
|
* ```js
|
|
249
|
-
* import url from 'url';
|
|
241
|
+
* import url from 'node:url';
|
|
250
242
|
*
|
|
251
243
|
* console.log(url.domainToASCII('español.com'));
|
|
252
244
|
* // Prints xn--espaol-zwa.com
|
|
@@ -264,10 +256,8 @@ declare module 'url' {
|
|
|
264
256
|
*
|
|
265
257
|
* It performs the inverse operation to {@link domainToASCII}.
|
|
266
258
|
*
|
|
267
|
-
* This feature is only available if the `node` executable was compiled with `ICU` enabled. If not, the domain names are passed through unchanged.
|
|
268
|
-
*
|
|
269
259
|
* ```js
|
|
270
|
-
* import url from 'url';
|
|
260
|
+
* import url from 'node:url';
|
|
271
261
|
*
|
|
272
262
|
* console.log(url.domainToUnicode('xn--espaol-zwa.com'));
|
|
273
263
|
* // Prints español.com
|
|
@@ -284,7 +274,7 @@ declare module 'url' {
|
|
|
284
274
|
* well as ensuring a cross-platform valid absolute path string.
|
|
285
275
|
*
|
|
286
276
|
* ```js
|
|
287
|
-
* import { fileURLToPath } from 'url';
|
|
277
|
+
* import { fileURLToPath } from 'node:url';
|
|
288
278
|
*
|
|
289
279
|
* const __filename = fileURLToPath(import.meta.url);
|
|
290
280
|
*
|
|
@@ -310,7 +300,7 @@ declare module 'url' {
|
|
|
310
300
|
* control characters are correctly encoded when converting into a File URL.
|
|
311
301
|
*
|
|
312
302
|
* ```js
|
|
313
|
-
* import { pathToFileURL } from 'url';
|
|
303
|
+
* import { pathToFileURL } from 'node:url';
|
|
314
304
|
*
|
|
315
305
|
* new URL('/foo#1', 'file:'); // Incorrect: file:///foo#1
|
|
316
306
|
* pathToFileURL('/foo#1'); // Correct: file:///foo%231 (POSIX)
|
|
@@ -328,7 +318,7 @@ declare module 'url' {
|
|
|
328
318
|
* expected by the `http.request()` and `https.request()` APIs.
|
|
329
319
|
*
|
|
330
320
|
* ```js
|
|
331
|
-
* import { urlToHttpOptions } from 'url';
|
|
321
|
+
* import { urlToHttpOptions } from 'node:url';
|
|
332
322
|
* const myURL = new URL('https://a:b@測試?abc#foo');
|
|
333
323
|
*
|
|
334
324
|
* console.log(urlToHttpOptions(myURL));
|
|
@@ -376,7 +366,7 @@ declare module 'url' {
|
|
|
376
366
|
* const {
|
|
377
367
|
* Blob,
|
|
378
368
|
* resolveObjectURL,
|
|
379
|
-
* } = require('buffer');
|
|
369
|
+
* } = require('node:buffer');
|
|
380
370
|
*
|
|
381
371
|
* const blob = new Blob(['hello']);
|
|
382
372
|
* const id = URL.createObjectURL(blob);
|
|
@@ -398,7 +388,7 @@ declare module 'url' {
|
|
|
398
388
|
static createObjectURL(blob: NodeBlob): string;
|
|
399
389
|
/**
|
|
400
390
|
* Removes the stored `Blob` identified by the given ID. Attempting to revoke a
|
|
401
|
-
* ID that isn
|
|
391
|
+
* ID that isn't registered will silently fail.
|
|
402
392
|
* @since v16.7.0
|
|
403
393
|
* @experimental
|
|
404
394
|
* @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
|
|
@@ -449,7 +439,7 @@ declare module 'url' {
|
|
|
449
439
|
* // Prints example.org
|
|
450
440
|
*
|
|
451
441
|
* // Setting the hostname does not change the port
|
|
452
|
-
* myURL.hostname = 'example.com
|
|
442
|
+
* myURL.hostname = 'example.com';
|
|
453
443
|
* console.log(myURL.href);
|
|
454
444
|
* // Prints https://example.com:81/foo
|
|
455
445
|
*
|
|
@@ -512,7 +502,7 @@ declare module 'url' {
|
|
|
512
502
|
*
|
|
513
503
|
* myURL.password = '123';
|
|
514
504
|
* console.log(myURL.href);
|
|
515
|
-
* // Prints https://abc:123@example.com
|
|
505
|
+
* // Prints https://abc:123@example.com/
|
|
516
506
|
* ```
|
|
517
507
|
*
|
|
518
508
|
* Invalid URL characters included in the value assigned to the `password` property
|
|
@@ -656,14 +646,14 @@ declare module 'url' {
|
|
|
656
646
|
* character, while `URLSearchParams` will always encode it:
|
|
657
647
|
*
|
|
658
648
|
* ```js
|
|
659
|
-
* const
|
|
649
|
+
* const myURL = new URL('https://example.org/abc?foo=~bar');
|
|
660
650
|
*
|
|
661
|
-
* console.log(
|
|
651
|
+
* console.log(myURL.search); // prints ?foo=~bar
|
|
662
652
|
*
|
|
663
653
|
* // Modify the URL via searchParams...
|
|
664
|
-
*
|
|
654
|
+
* myURL.searchParams.sort();
|
|
665
655
|
*
|
|
666
|
-
* console.log(
|
|
656
|
+
* console.log(myURL.search); // prints ?foo=%7Ebar
|
|
667
657
|
* ```
|
|
668
658
|
*/
|
|
669
659
|
readonly searchParams: URLSearchParams;
|
|
@@ -758,9 +748,12 @@ declare module 'url' {
|
|
|
758
748
|
*/
|
|
759
749
|
append(name: string, value: string): void;
|
|
760
750
|
/**
|
|
761
|
-
*
|
|
751
|
+
* If `value` is provided, removes all name-value pairs
|
|
752
|
+
* where name is `name` and value is `value`..
|
|
753
|
+
*
|
|
754
|
+
* If `value` is not provided, removes all name-value pairs whose name is `name`.
|
|
762
755
|
*/
|
|
763
|
-
delete(name: string): void;
|
|
756
|
+
delete(name: string, value?: string): void;
|
|
764
757
|
/**
|
|
765
758
|
* Returns an ES6 `Iterator` over each of the name-value pairs in the query.
|
|
766
759
|
* Each item of the iterator is a JavaScript `Array`. The first item of the `Array`is the `name`, the second item of the `Array` is the `value`.
|
|
@@ -796,9 +789,15 @@ declare module 'url' {
|
|
|
796
789
|
*/
|
|
797
790
|
getAll(name: string): string[];
|
|
798
791
|
/**
|
|
799
|
-
*
|
|
792
|
+
* Checks if the `URLSearchParams` object contains key-value pair(s) based on`name` and an optional `value` argument.
|
|
793
|
+
*
|
|
794
|
+
* If `value` is provided, returns `true` when name-value pair with
|
|
795
|
+
* same `name` and `value` exists.
|
|
796
|
+
*
|
|
797
|
+
* If `value` is not provided, returns `true` if there is at least one name-value
|
|
798
|
+
* pair whose name is `name`.
|
|
800
799
|
*/
|
|
801
|
-
has(name: string): boolean;
|
|
800
|
+
has(name: string, value?: string): boolean;
|
|
802
801
|
/**
|
|
803
802
|
* Returns an ES6 `Iterator` over the names of each name-value pair.
|
|
804
803
|
*
|
|
@@ -833,6 +832,11 @@ declare module 'url' {
|
|
|
833
832
|
* ```
|
|
834
833
|
*/
|
|
835
834
|
set(name: string, value: string): void;
|
|
835
|
+
/**
|
|
836
|
+
* The total number of parameter entries.
|
|
837
|
+
* @since v19.8.0
|
|
838
|
+
*/
|
|
839
|
+
readonly size: number;
|
|
836
840
|
/**
|
|
837
841
|
* Sort all existing name-value pairs in-place by their names. Sorting is done
|
|
838
842
|
* with a [stable sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm#Stability), so relative order between name-value pairs
|