@types/node 22.7.1 → 22.7.3
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/assert.d.ts +1 -1
- node/async_hooks.d.ts +1 -1
- node/buffer.d.ts +4 -4
- node/child_process.d.ts +34 -29
- node/cluster.d.ts +2 -1
- node/console.d.ts +2 -2
- node/crypto.d.ts +3 -3
- node/dns/promises.d.ts +5 -5
- node/dns.d.ts +5 -5
- node/domain.d.ts +2 -2
- node/fs/promises.d.ts +2 -2
- node/fs.d.ts +2 -2
- node/http.d.ts +2 -2
- node/http2.d.ts +24 -24
- node/https.d.ts +9 -9
- node/module.d.ts +3 -3
- node/net.d.ts +2 -2
- node/os.d.ts +1 -1
- node/package.json +2 -2
- node/path.d.ts +1 -1
- node/perf_hooks.d.ts +19 -19
- node/punycode.d.ts +1 -1
- node/querystring.d.ts +1 -1
- node/readline/promises.d.ts +1 -1
- node/readline.d.ts +9 -9
- node/repl.d.ts +4 -4
- node/sqlite.d.ts +1 -1
- node/stream/web.d.ts +17 -17
- node/stream.d.ts +15 -15
- node/string_decoder.d.ts +3 -3
- node/test.d.ts +2 -2
- node/timers/promises.d.ts +5 -5
- node/timers.d.ts +1 -1
- node/tls.d.ts +5 -5
- node/trace_events.d.ts +4 -4
- node/tty.d.ts +1 -1
- node/url.d.ts +7 -7
- node/util.d.ts +44 -44
- node/v8.d.ts +12 -12
- node/vm.d.ts +13 -13
- node/wasi.d.ts +1 -1
- node/worker_threads.d.ts +22 -22
- node/zlib.d.ts +8 -8
node/worker_threads.d.ts
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* JavaScript in parallel. To access it:
|
4
4
|
*
|
5
5
|
* ```js
|
6
|
-
*
|
6
|
+
* import worker from 'node:worker_threads';
|
7
7
|
* ```
|
8
8
|
*
|
9
9
|
* Workers (threads) are useful for performing CPU-intensive JavaScript operations.
|
@@ -14,9 +14,10 @@
|
|
14
14
|
* so by transferring `ArrayBuffer` instances or sharing `SharedArrayBuffer` instances.
|
15
15
|
*
|
16
16
|
* ```js
|
17
|
-
*
|
17
|
+
* import {
|
18
18
|
* Worker, isMainThread, parentPort, workerData,
|
19
|
-
* }
|
19
|
+
* } from 'node:worker_threads';
|
20
|
+
* import { parse } from 'some-js-parsing-library';
|
20
21
|
*
|
21
22
|
* if (isMainThread) {
|
22
23
|
* module.exports = function parseJSAsync(script) {
|
@@ -33,7 +34,6 @@
|
|
33
34
|
* });
|
34
35
|
* };
|
35
36
|
* } else {
|
36
|
-
* const { parse } = require('some-js-parsing-library');
|
37
37
|
* const script = workerData;
|
38
38
|
* parentPort.postMessage(parse(script));
|
39
39
|
* }
|
@@ -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
|
-
*
|
75
|
+
* import { MessageChannel } from '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
|
-
*
|
124
|
+
* import { MessageChannel } from 'node:worker_threads';
|
125
125
|
* const { port1, port2 } = new MessageChannel();
|
126
126
|
*
|
127
127
|
* port1.on('message', (message) => console.log(message));
|
@@ -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
|
-
*
|
146
|
+
* import { MessageChannel } from 'node:worker_threads';
|
147
147
|
* const { port1, port2 } = new MessageChannel();
|
148
148
|
*
|
149
149
|
* port1.on('message', (message) => console.log(message));
|
@@ -298,8 +298,8 @@ declare module "worker_threads" {
|
|
298
298
|
* Notable differences inside a Worker environment are:
|
299
299
|
*
|
300
300
|
* * The `process.stdin`, `process.stdout`, and `process.stderr` streams may be redirected by the parent thread.
|
301
|
-
* * The `
|
302
|
-
* * The `
|
301
|
+
* * The `import { isMainThread } from 'node:worker_threads'` variable is set to `false`.
|
302
|
+
* * The `import { parentPort } from 'node:worker_threads'` message port is available.
|
303
303
|
* * `process.exit()` does not stop the whole program, just the single thread,
|
304
304
|
* and `process.abort()` is not available.
|
305
305
|
* * `process.chdir()` and `process` methods that set group or user ids
|
@@ -334,10 +334,10 @@ declare module "worker_threads" {
|
|
334
334
|
* the thread barrier.
|
335
335
|
*
|
336
336
|
* ```js
|
337
|
-
*
|
338
|
-
*
|
337
|
+
* import assert from 'node:assert';
|
338
|
+
* import {
|
339
339
|
* Worker, MessageChannel, MessagePort, isMainThread, parentPort,
|
340
|
-
* }
|
340
|
+
* } from 'node:worker_threads';
|
341
341
|
* if (isMainThread) {
|
342
342
|
* const worker = new Worker(__filename);
|
343
343
|
* const subChannel = new MessageChannel();
|
@@ -377,7 +377,7 @@ declare module "worker_threads" {
|
|
377
377
|
readonly stderr: Readable;
|
378
378
|
/**
|
379
379
|
* An integer identifier for the referenced thread. Inside the worker thread,
|
380
|
-
* it is available as `
|
380
|
+
* it is available as `import { threadId } from 'node:worker_threads'`.
|
381
381
|
* This value is unique for each `Worker` instance inside a single process.
|
382
382
|
* @since v10.5.0
|
383
383
|
*/
|
@@ -513,11 +513,11 @@ declare module "worker_threads" {
|
|
513
513
|
* ```js
|
514
514
|
* 'use strict';
|
515
515
|
*
|
516
|
-
*
|
516
|
+
* import {
|
517
517
|
* isMainThread,
|
518
518
|
* BroadcastChannel,
|
519
519
|
* Worker,
|
520
|
-
* }
|
520
|
+
* } from 'node:worker_threads';
|
521
521
|
*
|
522
522
|
* const bc = new BroadcastChannel('hello');
|
523
523
|
*
|
@@ -571,7 +571,7 @@ declare module "worker_threads" {
|
|
571
571
|
* This operation cannot be undone.
|
572
572
|
*
|
573
573
|
* ```js
|
574
|
-
*
|
574
|
+
* import { MessageChannel, markAsUntransferable } from 'node:worker_threads';
|
575
575
|
*
|
576
576
|
* const pooledBuffer = new ArrayBuffer(8);
|
577
577
|
* const typedArray1 = new Uint8Array(pooledBuffer);
|
@@ -616,7 +616,7 @@ declare module "worker_threads" {
|
|
616
616
|
* that contains the message payload, corresponding to the oldest message in the `MessagePort`'s queue.
|
617
617
|
*
|
618
618
|
* ```js
|
619
|
-
*
|
619
|
+
* import { MessageChannel, receiveMessageOnPort } from 'node:worker_threads';
|
620
620
|
* const { port1, port2 } = new MessageChannel();
|
621
621
|
* port1.postMessage({ hello: 'world' });
|
622
622
|
*
|
@@ -642,12 +642,12 @@ declare module "worker_threads" {
|
|
642
642
|
* automatically.
|
643
643
|
*
|
644
644
|
* ```js
|
645
|
-
*
|
645
|
+
* import {
|
646
646
|
* Worker,
|
647
647
|
* isMainThread,
|
648
648
|
* setEnvironmentData,
|
649
649
|
* getEnvironmentData,
|
650
|
-
* }
|
650
|
+
* } from 'node:worker_threads';
|
651
651
|
*
|
652
652
|
* if (isMainThread) {
|
653
653
|
* setEnvironmentData('Hello', 'World!');
|
@@ -676,7 +676,7 @@ declare module "worker_threads" {
|
|
676
676
|
} from "worker_threads";
|
677
677
|
global {
|
678
678
|
/**
|
679
|
-
* `BroadcastChannel` class is a global reference for `
|
679
|
+
* `BroadcastChannel` class is a global reference for `import { BroadcastChannel } from 'worker_threads'`
|
680
680
|
* https://nodejs.org/api/globals.html#broadcastchannel
|
681
681
|
* @since v18.0.0
|
682
682
|
*/
|
@@ -686,7 +686,7 @@ declare module "worker_threads" {
|
|
686
686
|
} ? T
|
687
687
|
: typeof _BroadcastChannel;
|
688
688
|
/**
|
689
|
-
* `MessageChannel` class is a global reference for `
|
689
|
+
* `MessageChannel` class is a global reference for `import { MessageChannel } from 'worker_threads'`
|
690
690
|
* https://nodejs.org/api/globals.html#messagechannel
|
691
691
|
* @since v15.0.0
|
692
692
|
*/
|
@@ -696,7 +696,7 @@ declare module "worker_threads" {
|
|
696
696
|
} ? T
|
697
697
|
: typeof _MessageChannel;
|
698
698
|
/**
|
699
|
-
* `MessagePort` class is a global reference for `
|
699
|
+
* `MessagePort` class is a global reference for `import { MessagePort } from 'worker_threads'`
|
700
700
|
* https://nodejs.org/api/globals.html#messageport
|
701
701
|
* @since v15.0.0
|
702
702
|
*/
|
node/zlib.d.ts
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
* To access it:
|
6
6
|
*
|
7
7
|
* ```js
|
8
|
-
*
|
8
|
+
* import zlib from 'node:zlib';
|
9
9
|
* ```
|
10
10
|
*
|
11
11
|
* Compression and decompression are built around the Node.js
|
@@ -16,12 +16,12 @@
|
|
16
16
|
* stream:
|
17
17
|
*
|
18
18
|
* ```js
|
19
|
-
*
|
20
|
-
*
|
21
|
-
*
|
19
|
+
* import { createGzip } from 'node:zlib';
|
20
|
+
* import { pipeline } from 'node:stream';
|
21
|
+
* import {
|
22
22
|
* createReadStream,
|
23
23
|
* createWriteStream,
|
24
|
-
* }
|
24
|
+
* } from 'node:fs';
|
25
25
|
*
|
26
26
|
* const gzip = createGzip();
|
27
27
|
* const source = createReadStream('input.txt');
|
@@ -36,7 +36,7 @@
|
|
36
36
|
*
|
37
37
|
* // Or, Promisified
|
38
38
|
*
|
39
|
-
*
|
39
|
+
* import { promisify } from 'node:util';
|
40
40
|
* const pipe = promisify(pipeline);
|
41
41
|
*
|
42
42
|
* async function do_gzip(input, output) {
|
@@ -56,7 +56,7 @@
|
|
56
56
|
* It is also possible to compress or decompress data in a single step:
|
57
57
|
*
|
58
58
|
* ```js
|
59
|
-
*
|
59
|
+
* import { deflate, unzip } from 'node:zlib';
|
60
60
|
*
|
61
61
|
* const input = '.................................';
|
62
62
|
* deflate(input, (err, buffer) => {
|
@@ -78,7 +78,7 @@
|
|
78
78
|
*
|
79
79
|
* // Or, Promisified
|
80
80
|
*
|
81
|
-
*
|
81
|
+
* import { promisify } from 'node:util';
|
82
82
|
* const do_unzip = promisify(unzip);
|
83
83
|
*
|
84
84
|
* do_unzip(buffer)
|