@types/node 18.16.3 → 20.1.0
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 +71 -75
- node/async_hooks.d.ts +62 -42
- node/buffer.d.ts +127 -99
- node/child_process.d.ts +50 -54
- node/cluster.d.ts +12 -12
- node/console.d.ts +5 -5
- node/crypto.d.ts +209 -220
- node/dgram.d.ts +15 -15
- node/diagnostics_channel.d.ts +25 -26
- node/dns/promises.d.ts +6 -6
- node/dns.d.ts +24 -16
- node/domain.d.ts +4 -4
- node/events.d.ts +60 -60
- node/fs/promises.d.ts +78 -48
- node/fs.d.ts +117 -81
- node/http.d.ts +158 -147
- node/http2.d.ts +42 -46
- node/https.d.ts +52 -153
- node/index.d.ts +1 -1
- node/inspector.d.ts +10 -3
- node/module.d.ts +5 -4
- node/net.d.ts +21 -18
- node/os.d.ts +22 -18
- node/package.json +2 -2
- node/path.d.ts +4 -4
- node/perf_hooks.d.ts +28 -15
- node/process.d.ts +43 -46
- node/punycode.d.ts +1 -1
- node/querystring.d.ts +5 -5
- node/readline/promises.d.ts +6 -4
- node/readline.d.ts +15 -15
- node/repl.d.ts +9 -9
- node/stream/consumers.d.ts +1 -1
- node/stream.d.ts +88 -136
- node/string_decoder.d.ts +6 -6
- node/test.d.ts +423 -186
- node/timers/promises.d.ts +3 -3
- node/timers.d.ts +2 -2
- node/tls.d.ts +24 -16
- node/trace_events.d.ts +20 -9
- node/ts4.8/assert.d.ts +71 -75
- node/ts4.8/async_hooks.d.ts +62 -42
- node/ts4.8/buffer.d.ts +127 -99
- node/ts4.8/child_process.d.ts +50 -54
- node/ts4.8/cluster.d.ts +12 -12
- node/ts4.8/console.d.ts +5 -5
- node/ts4.8/crypto.d.ts +209 -220
- node/ts4.8/dgram.d.ts +15 -15
- node/ts4.8/diagnostics_channel.d.ts +25 -26
- node/ts4.8/dns/promises.d.ts +6 -6
- node/ts4.8/dns.d.ts +24 -16
- node/ts4.8/domain.d.ts +4 -4
- node/ts4.8/events.d.ts +60 -60
- node/ts4.8/fs/promises.d.ts +96 -45
- node/ts4.8/fs.d.ts +203 -67
- node/ts4.8/globals.d.ts +29 -28
- node/ts4.8/http.d.ts +198 -126
- node/ts4.8/http2.d.ts +42 -46
- node/ts4.8/https.d.ts +52 -153
- node/ts4.8/inspector.d.ts +10 -3
- node/ts4.8/module.d.ts +5 -4
- node/ts4.8/net.d.ts +24 -21
- node/ts4.8/os.d.ts +22 -18
- node/ts4.8/path.d.ts +4 -4
- node/ts4.8/perf_hooks.d.ts +28 -15
- node/ts4.8/process.d.ts +43 -46
- node/ts4.8/punycode.d.ts +1 -1
- node/ts4.8/querystring.d.ts +5 -5
- node/ts4.8/readline/promises.d.ts +6 -4
- node/ts4.8/readline.d.ts +15 -15
- node/ts4.8/repl.d.ts +9 -9
- node/ts4.8/stream/consumers.d.ts +1 -1
- node/ts4.8/stream.d.ts +91 -139
- node/ts4.8/string_decoder.d.ts +6 -6
- node/ts4.8/test.d.ts +423 -186
- node/ts4.8/timers/promises.d.ts +3 -3
- node/ts4.8/timers.d.ts +9 -2
- node/ts4.8/tls.d.ts +24 -16
- node/ts4.8/trace_events.d.ts +20 -9
- node/ts4.8/tty.d.ts +4 -5
- node/ts4.8/url.d.ts +26 -36
- node/ts4.8/util.d.ts +143 -116
- node/ts4.8/v8.d.ts +110 -16
- node/ts4.8/vm.d.ts +292 -42
- node/ts4.8/wasi.d.ts +13 -19
- node/ts4.8/worker_threads.d.ts +32 -34
- node/ts4.8/zlib.d.ts +11 -11
- node/tty.d.ts +4 -5
- node/url.d.ts +26 -36
- node/util.d.ts +146 -111
- node/v8.d.ts +110 -16
- node/vm.d.ts +292 -42
- node/wasi.d.ts +13 -19
- node/worker_threads.d.ts +32 -34
- node/zlib.d.ts +11 -11
node/child_process.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `child_process` module provides the ability to spawn subprocesses in
|
|
2
|
+
* The `node:child_process` module provides the ability to spawn subprocesses in
|
|
3
3
|
* a manner that is similar, but not identical, to [`popen(3)`](http://man7.org/linux/man-pages/man3/popen.3.html). This capability
|
|
4
4
|
* is primarily provided by the {@link spawn} function:
|
|
5
5
|
*
|
|
6
6
|
* ```js
|
|
7
|
-
* const { spawn } = require('child_process');
|
|
7
|
+
* const { spawn } = require('node:child_process');
|
|
8
8
|
* const ls = spawn('ls', ['-lh', '/usr']);
|
|
9
9
|
*
|
|
10
10
|
* ls.stdout.on('data', (data) => {
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
* without blocking the Node.js event loop. The {@link spawnSync} function provides equivalent functionality in a synchronous manner that blocks
|
|
45
45
|
* the event loop until the spawned process either exits or is terminated.
|
|
46
46
|
*
|
|
47
|
-
* For convenience, the `child_process` module provides a handful of
|
|
48
|
-
* and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on
|
|
47
|
+
* For convenience, the `node:child_process` module provides a handful of
|
|
48
|
+
* synchronous and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on
|
|
49
49
|
* top of {@link spawn} or {@link spawnSync}.
|
|
50
50
|
*
|
|
51
51
|
* * {@link exec}: spawns a shell and runs a command within that
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
* For certain use cases, such as automating shell scripts, the `synchronous counterparts` may be more convenient. In many cases, however,
|
|
64
64
|
* the synchronous methods can have significant impact on performance due to
|
|
65
65
|
* stalling the event loop while spawned processes complete.
|
|
66
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
66
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/child_process.js)
|
|
67
67
|
*/
|
|
68
68
|
declare module 'child_process' {
|
|
69
69
|
import { ObjectEncodingOptions } from 'node:fs';
|
|
@@ -94,8 +94,7 @@ declare module 'child_process' {
|
|
|
94
94
|
* `subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will
|
|
95
95
|
* refer to the same value.
|
|
96
96
|
*
|
|
97
|
-
* The `subprocess.stdin` property can be `undefined`
|
|
98
|
-
* not be successfully spawned.
|
|
97
|
+
* The `subprocess.stdin` property can be `null` or `undefined`if the child process could not be successfully spawned.
|
|
99
98
|
* @since v0.1.90
|
|
100
99
|
*/
|
|
101
100
|
stdin: Writable | null;
|
|
@@ -109,7 +108,7 @@ declare module 'child_process' {
|
|
|
109
108
|
* refer to the same value.
|
|
110
109
|
*
|
|
111
110
|
* ```js
|
|
112
|
-
* const { spawn } = require('child_process');
|
|
111
|
+
* const { spawn } = require('node:child_process');
|
|
113
112
|
*
|
|
114
113
|
* const subprocess = spawn('ls');
|
|
115
114
|
*
|
|
@@ -118,8 +117,7 @@ declare module 'child_process' {
|
|
|
118
117
|
* });
|
|
119
118
|
* ```
|
|
120
119
|
*
|
|
121
|
-
* The `subprocess.stdout` property can be `null` if the child process could
|
|
122
|
-
* not be successfully spawned.
|
|
120
|
+
* The `subprocess.stdout` property can be `null` or `undefined`if the child process could not be successfully spawned.
|
|
123
121
|
* @since v0.1.90
|
|
124
122
|
*/
|
|
125
123
|
stdout: Readable | null;
|
|
@@ -132,14 +130,13 @@ declare module 'child_process' {
|
|
|
132
130
|
* `subprocess.stderr` is an alias for `subprocess.stdio[2]`. Both properties will
|
|
133
131
|
* refer to the same value.
|
|
134
132
|
*
|
|
135
|
-
* The `subprocess.stderr` property can be `null` if the child process could
|
|
136
|
-
* not be successfully spawned.
|
|
133
|
+
* The `subprocess.stderr` property can be `null` or `undefined`if the child process could not be successfully spawned.
|
|
137
134
|
* @since v0.1.90
|
|
138
135
|
*/
|
|
139
136
|
stderr: Readable | null;
|
|
140
137
|
/**
|
|
141
138
|
* The `subprocess.channel` property is a reference to the child's IPC channel. If
|
|
142
|
-
* no IPC channel
|
|
139
|
+
* no IPC channel exists, this property is `undefined`.
|
|
143
140
|
* @since v7.1.0
|
|
144
141
|
*/
|
|
145
142
|
readonly channel?: Pipe | null | undefined;
|
|
@@ -154,16 +151,16 @@ declare module 'child_process' {
|
|
|
154
151
|
* in the array are `null`.
|
|
155
152
|
*
|
|
156
153
|
* ```js
|
|
157
|
-
* const assert = require('assert');
|
|
158
|
-
* const fs = require('fs');
|
|
159
|
-
* const child_process = require('child_process');
|
|
154
|
+
* const assert = require('node:assert');
|
|
155
|
+
* const fs = require('node:fs');
|
|
156
|
+
* const child_process = require('node:child_process');
|
|
160
157
|
*
|
|
161
158
|
* const subprocess = child_process.spawn('ls', {
|
|
162
159
|
* stdio: [
|
|
163
160
|
* 0, // Use parent's stdin for child.
|
|
164
161
|
* 'pipe', // Pipe child's stdout to parent.
|
|
165
162
|
* fs.openSync('err.out', 'w'), // Direct child's stderr to a file.
|
|
166
|
-
* ]
|
|
163
|
+
* ],
|
|
167
164
|
* });
|
|
168
165
|
*
|
|
169
166
|
* assert.strictEqual(subprocess.stdio[0], null);
|
|
@@ -204,7 +201,7 @@ declare module 'child_process' {
|
|
|
204
201
|
* emitted.
|
|
205
202
|
*
|
|
206
203
|
* ```js
|
|
207
|
-
* const { spawn } = require('child_process');
|
|
204
|
+
* const { spawn } = require('node:child_process');
|
|
208
205
|
* const grep = spawn('grep', ['ssh']);
|
|
209
206
|
*
|
|
210
207
|
* console.log(`Spawned child pid: ${grep.pid}`);
|
|
@@ -251,7 +248,7 @@ declare module 'child_process' {
|
|
|
251
248
|
* returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise.
|
|
252
249
|
*
|
|
253
250
|
* ```js
|
|
254
|
-
* const { spawn } = require('child_process');
|
|
251
|
+
* const { spawn } = require('node:child_process');
|
|
255
252
|
* const grep = spawn('grep', ['ssh']);
|
|
256
253
|
*
|
|
257
254
|
* grep.on('close', (code, signal) => {
|
|
@@ -284,7 +281,7 @@ declare module 'child_process' {
|
|
|
284
281
|
*
|
|
285
282
|
* ```js
|
|
286
283
|
* 'use strict';
|
|
287
|
-
* const { spawn } = require('child_process');
|
|
284
|
+
* const { spawn } = require('node:child_process');
|
|
288
285
|
*
|
|
289
286
|
* const subprocess = spawn(
|
|
290
287
|
* 'sh',
|
|
@@ -294,8 +291,8 @@ declare module 'child_process' {
|
|
|
294
291
|
* console.log(process.pid, 'is alive')
|
|
295
292
|
* }, 500);"`,
|
|
296
293
|
* ], {
|
|
297
|
-
* stdio: ['inherit', 'inherit', 'inherit']
|
|
298
|
-
* }
|
|
294
|
+
* stdio: ['inherit', 'inherit', 'inherit'],
|
|
295
|
+
* },
|
|
299
296
|
* );
|
|
300
297
|
*
|
|
301
298
|
* setTimeout(() => {
|
|
@@ -317,7 +314,7 @@ declare module 'child_process' {
|
|
|
317
314
|
* For example, in the parent script:
|
|
318
315
|
*
|
|
319
316
|
* ```js
|
|
320
|
-
* const cp = require('child_process');
|
|
317
|
+
* const cp = require('node:child_process');
|
|
321
318
|
* const n = cp.fork(`${__dirname}/sub.js`);
|
|
322
319
|
*
|
|
323
320
|
* n.on('message', (m) => {
|
|
@@ -371,10 +368,10 @@ declare module 'child_process' {
|
|
|
371
368
|
* a TCP server object to the child process as illustrated in the example below:
|
|
372
369
|
*
|
|
373
370
|
* ```js
|
|
374
|
-
* const subprocess = require('child_process').fork('subprocess.js');
|
|
371
|
+
* const subprocess = require('node:child_process').fork('subprocess.js');
|
|
375
372
|
*
|
|
376
373
|
* // Open up the server object and send the handle.
|
|
377
|
-
* const server = require('net').createServer();
|
|
374
|
+
* const server = require('node:net').createServer();
|
|
378
375
|
* server.on('connection', (socket) => {
|
|
379
376
|
* socket.end('handled by parent');
|
|
380
377
|
* });
|
|
@@ -398,10 +395,9 @@ declare module 'child_process' {
|
|
|
398
395
|
* Once the server is now shared between the parent and child, some connections
|
|
399
396
|
* can be handled by the parent and some by the child.
|
|
400
397
|
*
|
|
401
|
-
* While the example above uses a server created using the `net` module
|
|
402
|
-
* a `'message'` event instead of `'connection'` and using
|
|
403
|
-
*
|
|
404
|
-
* platforms.
|
|
398
|
+
* While the example above uses a server created using the `node:net` module,`node:dgram` module servers use exactly the same workflow with the exceptions of
|
|
399
|
+
* listening on a `'message'` event instead of `'connection'` and using`server.bind()` instead of `server.listen()`. This is, however, only
|
|
400
|
+
* supported on Unix platforms.
|
|
405
401
|
*
|
|
406
402
|
* #### Example: sending a socket object
|
|
407
403
|
*
|
|
@@ -410,13 +406,13 @@ declare module 'child_process' {
|
|
|
410
406
|
* handle connections with "normal" or "special" priority:
|
|
411
407
|
*
|
|
412
408
|
* ```js
|
|
413
|
-
* const { fork } = require('child_process');
|
|
409
|
+
* const { fork } = require('node:child_process');
|
|
414
410
|
* const normal = fork('subprocess.js', ['normal']);
|
|
415
411
|
* const special = fork('subprocess.js', ['special']);
|
|
416
412
|
*
|
|
417
413
|
* // Open up the server and send sockets to child. Use pauseOnConnect to prevent
|
|
418
414
|
* // the sockets from being read before they are sent to the child process.
|
|
419
|
-
* const server = require('net').createServer({ pauseOnConnect: true });
|
|
415
|
+
* const server = require('node:net').createServer({ pauseOnConnect: true });
|
|
420
416
|
* server.on('connection', (socket) => {
|
|
421
417
|
*
|
|
422
418
|
* // If this is special priority...
|
|
@@ -482,11 +478,11 @@ declare module 'child_process' {
|
|
|
482
478
|
* the child and the parent.
|
|
483
479
|
*
|
|
484
480
|
* ```js
|
|
485
|
-
* const { spawn } = require('child_process');
|
|
481
|
+
* const { spawn } = require('node:child_process');
|
|
486
482
|
*
|
|
487
483
|
* const subprocess = spawn(process.argv[0], ['child_program.js'], {
|
|
488
484
|
* detached: true,
|
|
489
|
-
* stdio: 'ignore'
|
|
485
|
+
* stdio: 'ignore',
|
|
490
486
|
* });
|
|
491
487
|
*
|
|
492
488
|
* subprocess.unref();
|
|
@@ -500,11 +496,11 @@ declare module 'child_process' {
|
|
|
500
496
|
* to wait for the child to exit before exiting itself.
|
|
501
497
|
*
|
|
502
498
|
* ```js
|
|
503
|
-
* const { spawn } = require('child_process');
|
|
499
|
+
* const { spawn } = require('node:child_process');
|
|
504
500
|
*
|
|
505
501
|
* const subprocess = spawn(process.argv[0], ['child_program.js'], {
|
|
506
502
|
* detached: true,
|
|
507
|
-
* stdio: 'ignore'
|
|
503
|
+
* stdio: 'ignore',
|
|
508
504
|
* });
|
|
509
505
|
*
|
|
510
506
|
* subprocess.unref();
|
|
@@ -663,7 +659,7 @@ declare module 'child_process' {
|
|
|
663
659
|
* ```js
|
|
664
660
|
* const defaults = {
|
|
665
661
|
* cwd: undefined,
|
|
666
|
-
* env: process.env
|
|
662
|
+
* env: process.env,
|
|
667
663
|
* };
|
|
668
664
|
* ```
|
|
669
665
|
*
|
|
@@ -682,7 +678,7 @@ declare module 'child_process' {
|
|
|
682
678
|
* exit code:
|
|
683
679
|
*
|
|
684
680
|
* ```js
|
|
685
|
-
* const { spawn } = require('child_process');
|
|
681
|
+
* const { spawn } = require('node:child_process');
|
|
686
682
|
* const ls = spawn('ls', ['-lh', '/usr']);
|
|
687
683
|
*
|
|
688
684
|
* ls.stdout.on('data', (data) => {
|
|
@@ -701,7 +697,7 @@ declare module 'child_process' {
|
|
|
701
697
|
* Example: A very elaborate way to run `ps ax | grep ssh`
|
|
702
698
|
*
|
|
703
699
|
* ```js
|
|
704
|
-
* const { spawn } = require('child_process');
|
|
700
|
+
* const { spawn } = require('node:child_process');
|
|
705
701
|
* const ps = spawn('ps', ['ax']);
|
|
706
702
|
* const grep = spawn('grep', ['ssh']);
|
|
707
703
|
*
|
|
@@ -738,7 +734,7 @@ declare module 'child_process' {
|
|
|
738
734
|
* Example of checking for failed `spawn`:
|
|
739
735
|
*
|
|
740
736
|
* ```js
|
|
741
|
-
* const { spawn } = require('child_process');
|
|
737
|
+
* const { spawn } = require('node:child_process');
|
|
742
738
|
* const subprocess = spawn('bad_command');
|
|
743
739
|
*
|
|
744
740
|
* subprocess.on('error', (err) => {
|
|
@@ -749,14 +745,14 @@ declare module 'child_process' {
|
|
|
749
745
|
* Certain platforms (macOS, Linux) will use the value of `argv[0]` for the process
|
|
750
746
|
* title while others (Windows, SunOS) will use `command`.
|
|
751
747
|
*
|
|
752
|
-
* Node.js
|
|
753
|
-
*
|
|
748
|
+
* Node.js overwrites `argv[0]` with `process.execPath` on startup, so`process.argv[0]` in a Node.js child process will not match the `argv0`parameter passed to `spawn` from the parent. Retrieve
|
|
749
|
+
* it with the`process.argv0` property instead.
|
|
754
750
|
*
|
|
755
751
|
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
|
756
752
|
* the error passed to the callback will be an `AbortError`:
|
|
757
753
|
*
|
|
758
754
|
* ```js
|
|
759
|
-
* const { spawn } = require('child_process');
|
|
755
|
+
* const { spawn } = require('node:child_process');
|
|
760
756
|
* const controller = new AbortController();
|
|
761
757
|
* const { signal } = controller;
|
|
762
758
|
* const grep = spawn('grep', ['ssh'], { signal });
|
|
@@ -815,7 +811,7 @@ declare module 'child_process' {
|
|
|
815
811
|
* need to be dealt with accordingly:
|
|
816
812
|
*
|
|
817
813
|
* ```js
|
|
818
|
-
* const { exec } = require('child_process');
|
|
814
|
+
* const { exec } = require('node:child_process');
|
|
819
815
|
*
|
|
820
816
|
* exec('"/path/to/test file/test.sh" arg1 arg2');
|
|
821
817
|
* // Double quotes are used so that the space in the path is not interpreted as
|
|
@@ -841,7 +837,7 @@ declare module 'child_process' {
|
|
|
841
837
|
* encoding, `Buffer` objects will be passed to the callback instead.
|
|
842
838
|
*
|
|
843
839
|
* ```js
|
|
844
|
-
* const { exec } = require('child_process');
|
|
840
|
+
* const { exec } = require('node:child_process');
|
|
845
841
|
* exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
|
|
846
842
|
* if (error) {
|
|
847
843
|
* console.error(`exec error: ${error}`);
|
|
@@ -866,8 +862,8 @@ declare module 'child_process' {
|
|
|
866
862
|
* callback, but with two additional properties `stdout` and `stderr`.
|
|
867
863
|
*
|
|
868
864
|
* ```js
|
|
869
|
-
* const util = require('util');
|
|
870
|
-
* const exec = util.promisify(require('child_process').exec);
|
|
865
|
+
* const util = require('node:util');
|
|
866
|
+
* const exec = util.promisify(require('node:child_process').exec);
|
|
871
867
|
*
|
|
872
868
|
* async function lsExample() {
|
|
873
869
|
* const { stdout, stderr } = await exec('ls');
|
|
@@ -881,11 +877,11 @@ declare module 'child_process' {
|
|
|
881
877
|
* the error passed to the callback will be an `AbortError`:
|
|
882
878
|
*
|
|
883
879
|
* ```js
|
|
884
|
-
* const { exec } = require('child_process');
|
|
880
|
+
* const { exec } = require('node:child_process');
|
|
885
881
|
* const controller = new AbortController();
|
|
886
882
|
* const { signal } = controller;
|
|
887
883
|
* const child = exec('grep ssh', { signal }, (error) => {
|
|
888
|
-
* console.
|
|
884
|
+
* console.error(error); // an AbortError
|
|
889
885
|
* });
|
|
890
886
|
* controller.abort();
|
|
891
887
|
* ```
|
|
@@ -995,7 +991,7 @@ declare module 'child_process' {
|
|
|
995
991
|
* supported.
|
|
996
992
|
*
|
|
997
993
|
* ```js
|
|
998
|
-
* const { execFile } = require('child_process');
|
|
994
|
+
* const { execFile } = require('node:child_process');
|
|
999
995
|
* const child = execFile('node', ['--version'], (error, stdout, stderr) => {
|
|
1000
996
|
* if (error) {
|
|
1001
997
|
* throw error;
|
|
@@ -1018,8 +1014,8 @@ declare module 'child_process' {
|
|
|
1018
1014
|
* callback, but with two additional properties `stdout` and `stderr`.
|
|
1019
1015
|
*
|
|
1020
1016
|
* ```js
|
|
1021
|
-
* const util = require('util');
|
|
1022
|
-
* const execFile = util.promisify(require('child_process').execFile);
|
|
1017
|
+
* const util = require('node:util');
|
|
1018
|
+
* const execFile = util.promisify(require('node:child_process').execFile);
|
|
1023
1019
|
* async function getVersion() {
|
|
1024
1020
|
* const { stdout } = await execFile('node', ['--version']);
|
|
1025
1021
|
* console.log(stdout);
|
|
@@ -1035,11 +1031,11 @@ declare module 'child_process' {
|
|
|
1035
1031
|
* the error passed to the callback will be an `AbortError`:
|
|
1036
1032
|
*
|
|
1037
1033
|
* ```js
|
|
1038
|
-
* const { execFile } = require('child_process');
|
|
1034
|
+
* const { execFile } = require('node:child_process');
|
|
1039
1035
|
* const controller = new AbortController();
|
|
1040
1036
|
* const { signal } = controller;
|
|
1041
1037
|
* const child = execFile('node', ['--version'], { signal }, (error) => {
|
|
1042
|
-
* console.
|
|
1038
|
+
* console.error(error); // an AbortError
|
|
1043
1039
|
* });
|
|
1044
1040
|
* controller.abort();
|
|
1045
1041
|
* ```
|
|
@@ -1231,7 +1227,7 @@ declare module 'child_process' {
|
|
|
1231
1227
|
* console.log(`Hello from ${process.argv[2]}!`);
|
|
1232
1228
|
* }, 1_000);
|
|
1233
1229
|
* } else {
|
|
1234
|
-
* const { fork } = require('child_process');
|
|
1230
|
+
* const { fork } = require('node:child_process');
|
|
1235
1231
|
* const controller = new AbortController();
|
|
1236
1232
|
* const { signal } = controller;
|
|
1237
1233
|
* const child = fork(__filename, ['child'], { signal });
|
node/cluster.d.ts
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
* server ports.
|
|
9
9
|
*
|
|
10
10
|
* ```js
|
|
11
|
-
* import cluster from 'cluster';
|
|
12
|
-
* import http from 'http';
|
|
13
|
-
* import {
|
|
14
|
-
* import process from 'process';
|
|
11
|
+
* import cluster from 'node:cluster';
|
|
12
|
+
* import http from 'node:http';
|
|
13
|
+
* import { availableParallelism } from 'node:os';
|
|
14
|
+
* import process from 'node:process';
|
|
15
15
|
*
|
|
16
|
-
* const numCPUs =
|
|
16
|
+
* const numCPUs = availableParallelism();
|
|
17
17
|
*
|
|
18
18
|
* if (cluster.isPrimary) {
|
|
19
19
|
* console.log(`Primary ${process.pid} is running`);
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
* ```
|
|
51
51
|
*
|
|
52
52
|
* On Windows, it is not yet possible to set up a named pipe server in a worker.
|
|
53
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
53
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/cluster.js)
|
|
54
54
|
*/
|
|
55
55
|
declare module 'cluster' {
|
|
56
56
|
import * as child from 'node:child_process';
|
|
@@ -183,7 +183,7 @@ declare module 'cluster' {
|
|
|
183
183
|
* });
|
|
184
184
|
*
|
|
185
185
|
* } else if (cluster.isWorker) {
|
|
186
|
-
* const net = require('net');
|
|
186
|
+
* const net = require('node:net');
|
|
187
187
|
* const server = net.createServer((socket) => {
|
|
188
188
|
* // Connections never end
|
|
189
189
|
* });
|
|
@@ -213,12 +213,12 @@ declare module 'cluster' {
|
|
|
213
213
|
* because of exiting or being signaled). Otherwise, it returns `false`.
|
|
214
214
|
*
|
|
215
215
|
* ```js
|
|
216
|
-
* import cluster from 'cluster';
|
|
217
|
-
* import http from 'http';
|
|
218
|
-
* import {
|
|
219
|
-
* import process from 'process';
|
|
216
|
+
* import cluster from 'node:cluster';
|
|
217
|
+
* import http from 'node:http';
|
|
218
|
+
* import { availableParallelism } from 'node:os';
|
|
219
|
+
* import process from 'node:process';
|
|
220
220
|
*
|
|
221
|
-
* const numCPUs =
|
|
221
|
+
* const numCPUs = availableParallelism();
|
|
222
222
|
*
|
|
223
223
|
* if (cluster.isPrimary) {
|
|
224
224
|
* console.log(`Primary ${process.pid} is running`);
|
node/console.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `console` module provides a simple debugging console that is similar to
|
|
3
|
-
* JavaScript console mechanism provided by web browsers.
|
|
2
|
+
* The `node:console` module provides a simple debugging console that is similar to
|
|
3
|
+
* the JavaScript console mechanism provided by web browsers.
|
|
4
4
|
*
|
|
5
5
|
* The module exports two specific components:
|
|
6
6
|
*
|
|
7
|
-
* * A `Console` class with methods such as `console.log()`, `console.error()
|
|
8
|
-
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
|
|
7
|
+
* * A `Console` class with methods such as `console.log()`, `console.error()`, and`console.warn()` that can be used to write to any Node.js stream.
|
|
8
|
+
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('node:console')`.
|
|
9
9
|
*
|
|
10
10
|
* _**Warning**_: The global console object's methods are neither consistently
|
|
11
11
|
* synchronous like the browser APIs they resemble, nor are they consistently
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
* myConsole.warn(`Danger ${name}! Danger!`);
|
|
54
54
|
* // Prints: Danger Will Robinson! Danger!, to err
|
|
55
55
|
* ```
|
|
56
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
56
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/console.js)
|
|
57
57
|
*/
|
|
58
58
|
declare module 'console' {
|
|
59
59
|
import console = require('node:console');
|