@idlebox/stripe-node-types 24.0.14 → 24.0.15
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.
- package/README.md +1 -1
- package/assert/strict.d.ts +98 -1
- package/assert.d.ts +147 -248
- package/async_hooks.d.ts +5 -5
- package/buffer.buffer.d.ts +9 -6
- package/buffer.d.ts +49 -169
- package/child_process.d.ts +102 -223
- package/cluster.d.ts +236 -329
- package/console.d.ts +45 -346
- package/constants.d.ts +0 -1
- package/crypto.d.ts +698 -1149
- package/dgram.d.ts +15 -50
- package/diagnostics_channel.d.ts +1 -3
- package/dns.d.ts +135 -131
- package/domain.d.ts +10 -14
- package/events.d.ts +846 -722
- package/fs/promises.d.ts +102 -53
- package/fs.d.ts +714 -484
- package/globals.d.ts +130 -347
- package/globals.typedarray.d.ts +79 -0
- package/http.d.ts +343 -246
- package/http2.d.ts +563 -711
- package/https.d.ts +70 -216
- package/index.d.ts +24 -3
- package/inspector/promises.d.ts +54 -0
- package/inspector.d.ts +167 -3938
- package/inspector.generated.d.ts +4242 -0
- package/module.d.ts +45 -95
- package/net.d.ts +87 -186
- package/os.d.ts +17 -6
- package/package.json +3 -8
- package/path/posix.d.ts +20 -0
- package/path/win32.d.ts +20 -0
- package/path.d.ts +117 -122
- package/perf_hooks.d.ts +295 -644
- package/process.d.ts +177 -138
- package/punycode.d.ts +2 -2
- package/querystring.d.ts +1 -1
- package/quic.d.ts +926 -0
- package/readline/promises.d.ts +1 -1
- package/readline.d.ts +65 -118
- package/repl.d.ts +83 -96
- package/sea.d.ts +10 -1
- package/sqlite.d.ts +262 -13
- package/stream/consumers.d.ts +7 -7
- package/stream/promises.d.ts +133 -12
- package/stream/web.d.ts +173 -495
- package/stream.d.ts +593 -490
- package/string_decoder.d.ts +3 -3
- package/test/reporters.d.ts +112 -0
- package/test.d.ts +223 -199
- package/timers/promises.d.ts +1 -1
- package/timers.d.ts +1 -129
- package/tls.d.ts +148 -163
- package/trace_events.d.ts +6 -6
- package/ts5.6/buffer.buffer.d.ts +10 -8
- package/ts5.6/globals.typedarray.d.ts +16 -0
- package/ts5.6/index.d.ts +24 -3
- package/ts5.7/index.d.ts +24 -3
- package/tty.d.ts +55 -13
- package/url.d.ts +92 -587
- package/util/types.d.ts +571 -0
- package/util.d.ts +143 -792
- package/v8.d.ts +67 -7
- package/vm.d.ts +252 -108
- package/wasi.d.ts +23 -2
- package/web-globals/abortcontroller.d.ts +75 -0
- package/web-globals/blob.d.ts +39 -0
- package/{ts5.1/compatibility/disposable.d.ts → web-globals/console.d.ts} +6 -9
- package/web-globals/crypto.d.ts +55 -0
- package/web-globals/domexception.d.ts +84 -0
- package/web-globals/encoding.d.ts +27 -0
- package/{dom-events.d.ts → web-globals/events.d.ts} +57 -50
- package/web-globals/fetch.d.ts +70 -0
- package/web-globals/importmeta.d.ts +29 -0
- package/web-globals/messaging.d.ts +39 -0
- package/web-globals/navigator.d.ts +41 -0
- package/web-globals/performance.d.ts +61 -0
- package/web-globals/storage.d.ts +40 -0
- package/web-globals/streams.d.ts +131 -0
- package/web-globals/timers.d.ts +60 -0
- package/web-globals/url.d.ts +40 -0
- package/worker_threads.d.ts +291 -349
- package/zlib.d.ts +44 -94
- package/ts5.1/index.d.ts +0 -115
package/cluster.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
/**
|
|
17
17
|
* Clusters of Node.js processes can be used to run multiple instances of Node.js
|
|
18
18
|
* that can distribute workloads among their application threads. When process isolation
|
|
19
|
-
* is not needed, use the [`worker_threads`](https://nodejs.org/docs/latest-
|
|
19
|
+
* is not needed, use the [`worker_threads`](https://nodejs.org/docs/latest-v25.x/api/worker_threads.html)
|
|
20
20
|
* module instead, which allows running multiple application threads within a single Node.js instance.
|
|
21
21
|
*
|
|
22
22
|
* The cluster module allows easy creation of child processes that all share
|
|
@@ -65,91 +65,14 @@
|
|
|
65
65
|
* ```
|
|
66
66
|
*
|
|
67
67
|
* On Windows, it is not yet possible to set up a named pipe server in a worker.
|
|
68
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
68
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/cluster.js)
|
|
69
69
|
*/
|
|
70
70
|
|
|
71
71
|
declare module "node:cluster" {
|
|
72
|
-
import * as
|
|
73
|
-
import EventEmitter
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
export interface ClusterSettings {
|
|
77
|
-
/**
|
|
78
|
-
* List of string arguments passed to the Node.js executable.
|
|
79
|
-
* @default process.execArgv
|
|
80
|
-
*/
|
|
81
|
-
execArgv?: string[] | undefined;
|
|
82
|
-
/**
|
|
83
|
-
* File path to worker file.
|
|
84
|
-
* @default process.argv[1]
|
|
85
|
-
*/
|
|
86
|
-
exec?: string | undefined;
|
|
87
|
-
/**
|
|
88
|
-
* String arguments passed to worker.
|
|
89
|
-
* @default process.argv.slice(2)
|
|
90
|
-
*/
|
|
91
|
-
args?: string[] | undefined;
|
|
92
|
-
/**
|
|
93
|
-
* Whether or not to send output to parent's stdio.
|
|
94
|
-
* @default false
|
|
95
|
-
*/
|
|
96
|
-
silent?: boolean | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* Configures the stdio of forked processes. Because the cluster module relies on IPC to function, this configuration must
|
|
99
|
-
* contain an `'ipc'` entry. When this option is provided, it overrides `silent`. See [`child_prcess.spawn()`](https://nodejs.org/docs/latest-v24.x/api/child_process.html#child_processspawncommand-args-options)'s
|
|
100
|
-
* [`stdio`](https://nodejs.org/docs/latest-v24.x/api/child_process.html#optionsstdio).
|
|
101
|
-
*/
|
|
102
|
-
stdio?: any[] | undefined;
|
|
103
|
-
/**
|
|
104
|
-
* Sets the user identity of the process. (See [`setuid(2)`](https://man7.org/linux/man-pages/man2/setuid.2.html).)
|
|
105
|
-
*/
|
|
106
|
-
uid?: number | undefined;
|
|
107
|
-
/**
|
|
108
|
-
* Sets the group identity of the process. (See [`setgid(2)`](https://man7.org/linux/man-pages/man2/setgid.2.html).)
|
|
109
|
-
*/
|
|
110
|
-
gid?: number | undefined;
|
|
111
|
-
/**
|
|
112
|
-
* Sets inspector port of worker. This can be a number, or a function that takes no arguments and returns a number.
|
|
113
|
-
* By default each worker gets its own port, incremented from the primary's `process.debugPort`.
|
|
114
|
-
*/
|
|
115
|
-
inspectPort?: number | (() => number) | undefined;
|
|
116
|
-
/**
|
|
117
|
-
* Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`.
|
|
118
|
-
* See [Advanced serialization for `child_process`](https://nodejs.org/docs/latest-v24.x/api/child_process.html#advanced-serialization) for more details.
|
|
119
|
-
* @default false
|
|
120
|
-
*/
|
|
121
|
-
serialization?: SerializationType | undefined;
|
|
122
|
-
/**
|
|
123
|
-
* Current working directory of the worker process.
|
|
124
|
-
* @default undefined (inherits from parent process)
|
|
125
|
-
*/
|
|
126
|
-
cwd?: string | undefined;
|
|
127
|
-
/**
|
|
128
|
-
* Hide the forked processes console window that would normally be created on Windows systems.
|
|
129
|
-
* @default false
|
|
130
|
-
*/
|
|
131
|
-
windowsHide?: boolean | undefined;
|
|
132
|
-
}
|
|
133
|
-
export interface Address {
|
|
134
|
-
address: string;
|
|
135
|
-
port: number;
|
|
136
|
-
/**
|
|
137
|
-
* The `addressType` is one of:
|
|
138
|
-
*
|
|
139
|
-
* * `4` (TCPv4)
|
|
140
|
-
* * `6` (TCPv6)
|
|
141
|
-
* * `-1` (Unix domain socket)
|
|
142
|
-
* * `'udp4'` or `'udp6'` (UDPv4 or UDPv6)
|
|
143
|
-
*/
|
|
144
|
-
addressType: 4 | 6 | -1 | "udp4" | "udp6";
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* A `Worker` object contains all public information and method about a worker.
|
|
148
|
-
* In the primary it can be obtained using `cluster.workers`. In a worker
|
|
149
|
-
* it can be obtained using `cluster.worker`.
|
|
150
|
-
* @since v0.7.0
|
|
151
|
-
*/
|
|
152
|
-
export class Worker extends EventEmitter {
|
|
72
|
+
import * as child_process from 'node:child_process';
|
|
73
|
+
import { EventEmitter, InternalEventEmitter } from 'node:events';
|
|
74
|
+
class Worker implements EventEmitter {
|
|
75
|
+
constructor(options?: cluster.WorkerOptions);
|
|
153
76
|
/**
|
|
154
77
|
* Each new worker is given its own unique id, this id is stored in the `id`.
|
|
155
78
|
*
|
|
@@ -158,21 +81,21 @@ declare module "node:cluster" {
|
|
|
158
81
|
*/
|
|
159
82
|
id: number;
|
|
160
83
|
/**
|
|
161
|
-
* All workers are created using [`child_process.fork()`](https://nodejs.org/docs/latest-
|
|
84
|
+
* All workers are created using [`child_process.fork()`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#child_processforkmodulepath-args-options), the returned object
|
|
162
85
|
* from this function is stored as `.process`. In a worker, the global `process` is stored.
|
|
163
86
|
*
|
|
164
|
-
* See: [Child Process module](https://nodejs.org/docs/latest-
|
|
87
|
+
* See: [Child Process module](https://nodejs.org/docs/latest-v25.x/api/child_process.html#child_processforkmodulepath-args-options).
|
|
165
88
|
*
|
|
166
89
|
* Workers will call `process.exit(0)` if the `'disconnect'` event occurs
|
|
167
90
|
* on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
|
|
168
91
|
* accidental disconnection.
|
|
169
92
|
* @since v0.7.0
|
|
170
93
|
*/
|
|
171
|
-
process:
|
|
94
|
+
process: child_process.ChildProcess;
|
|
172
95
|
/**
|
|
173
96
|
* Send a message to a worker or primary, optionally with a handle.
|
|
174
97
|
*
|
|
175
|
-
* In the primary, this sends a message to a specific worker. It is identical to [`ChildProcess.send()`](https://nodejs.org/docs/latest-
|
|
98
|
+
* In the primary, this sends a message to a specific worker. It is identical to [`ChildProcess.send()`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#subprocesssendmessage-sendhandle-options-callback).
|
|
176
99
|
*
|
|
177
100
|
* In a worker, this sends a message to the primary. It is identical to `process.send()`.
|
|
178
101
|
*
|
|
@@ -192,16 +115,16 @@ declare module "node:cluster" {
|
|
|
192
115
|
* @since v0.7.0
|
|
193
116
|
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles.
|
|
194
117
|
*/
|
|
195
|
-
send(message:
|
|
118
|
+
send(message: child_process.Serializable, callback?: (error: Error | null) => void): boolean;
|
|
196
119
|
send(
|
|
197
|
-
message:
|
|
198
|
-
sendHandle:
|
|
120
|
+
message: child_process.Serializable,
|
|
121
|
+
sendHandle: child_process.SendHandle,
|
|
199
122
|
callback?: (error: Error | null) => void,
|
|
200
123
|
): boolean;
|
|
201
124
|
send(
|
|
202
|
-
message:
|
|
203
|
-
sendHandle:
|
|
204
|
-
options?:
|
|
125
|
+
message: child_process.Serializable,
|
|
126
|
+
sendHandle: child_process.SendHandle,
|
|
127
|
+
options?: child_process.MessageOptions,
|
|
205
128
|
callback?: (error: Error | null) => void,
|
|
206
129
|
): boolean;
|
|
207
130
|
/**
|
|
@@ -214,7 +137,7 @@ declare module "node:cluster" {
|
|
|
214
137
|
* This method is aliased as `worker.destroy()` for backwards compatibility.
|
|
215
138
|
*
|
|
216
139
|
* In a worker, `process.kill()` exists, but it is not this function;
|
|
217
|
-
* it is [`kill()`](https://nodejs.org/docs/latest-
|
|
140
|
+
* it is [`kill()`](https://nodejs.org/docs/latest-v25.x/api/process.html#processkillpid-signal).
|
|
218
141
|
* @since v0.9.12
|
|
219
142
|
* @param [signal='SIGTERM'] Name of the kill signal to send to the worker process.
|
|
220
143
|
*/
|
|
@@ -351,241 +274,225 @@ declare module "node:cluster" {
|
|
|
351
274
|
* @since v6.0.0
|
|
352
275
|
*/
|
|
353
276
|
exitedAfterDisconnect: boolean;
|
|
354
|
-
/**
|
|
355
|
-
* events.EventEmitter
|
|
356
|
-
* 1. disconnect
|
|
357
|
-
* 2. error
|
|
358
|
-
* 3. exit
|
|
359
|
-
* 4. listening
|
|
360
|
-
* 5. message
|
|
361
|
-
* 6. online
|
|
362
|
-
*/
|
|
363
|
-
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
364
|
-
addListener(event: "disconnect", listener: () => void): this;
|
|
365
|
-
addListener(event: "error", listener: (error: Error) => void): this;
|
|
366
|
-
addListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
|
367
|
-
addListener(event: "listening", listener: (address: Address) => void): this;
|
|
368
|
-
addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
|
369
|
-
addListener(event: "online", listener: () => void): this;
|
|
370
|
-
emit(event: string | symbol, ...args: any[]): boolean;
|
|
371
|
-
emit(event: "disconnect"): boolean;
|
|
372
|
-
emit(event: "error", error: Error): boolean;
|
|
373
|
-
emit(event: "exit", code: number, signal: string): boolean;
|
|
374
|
-
emit(event: "listening", address: Address): boolean;
|
|
375
|
-
emit(event: "message", message: any, handle: net.Socket | net.Server): boolean;
|
|
376
|
-
emit(event: "online"): boolean;
|
|
377
|
-
on(event: string, listener: (...args: any[]) => void): this;
|
|
378
|
-
on(event: "disconnect", listener: () => void): this;
|
|
379
|
-
on(event: "error", listener: (error: Error) => void): this;
|
|
380
|
-
on(event: "exit", listener: (code: number, signal: string) => void): this;
|
|
381
|
-
on(event: "listening", listener: (address: Address) => void): this;
|
|
382
|
-
on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
|
383
|
-
on(event: "online", listener: () => void): this;
|
|
384
|
-
once(event: string, listener: (...args: any[]) => void): this;
|
|
385
|
-
once(event: "disconnect", listener: () => void): this;
|
|
386
|
-
once(event: "error", listener: (error: Error) => void): this;
|
|
387
|
-
once(event: "exit", listener: (code: number, signal: string) => void): this;
|
|
388
|
-
once(event: "listening", listener: (address: Address) => void): this;
|
|
389
|
-
once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
|
390
|
-
once(event: "online", listener: () => void): this;
|
|
391
|
-
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
392
|
-
prependListener(event: "disconnect", listener: () => void): this;
|
|
393
|
-
prependListener(event: "error", listener: (error: Error) => void): this;
|
|
394
|
-
prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
|
395
|
-
prependListener(event: "listening", listener: (address: Address) => void): this;
|
|
396
|
-
prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
|
397
|
-
prependListener(event: "online", listener: () => void): this;
|
|
398
|
-
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
|
399
|
-
prependOnceListener(event: "disconnect", listener: () => void): this;
|
|
400
|
-
prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
|
401
|
-
prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
|
402
|
-
prependOnceListener(event: "listening", listener: (address: Address) => void): this;
|
|
403
|
-
prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
|
404
|
-
prependOnceListener(event: "online", listener: () => void): this;
|
|
405
277
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
278
|
+
interface Worker extends InternalEventEmitter<cluster.WorkerEventMap> {}
|
|
279
|
+
type _Worker = Worker;
|
|
280
|
+
namespace cluster {
|
|
281
|
+
interface Worker extends _Worker {}
|
|
282
|
+
interface WorkerOptions {
|
|
283
|
+
id?: number | undefined;
|
|
284
|
+
process?: child_process.ChildProcess | undefined;
|
|
285
|
+
state?: string | undefined;
|
|
286
|
+
}
|
|
287
|
+
interface WorkerEventMap {
|
|
288
|
+
"disconnect": [];
|
|
289
|
+
"error": [error: Error];
|
|
290
|
+
"exit": [code: number, signal: string];
|
|
291
|
+
"listening": [address: Address];
|
|
292
|
+
"message": [message: any, handle: child_process.SendHandle];
|
|
293
|
+
"online": [];
|
|
294
|
+
}
|
|
295
|
+
interface ClusterSettings {
|
|
296
|
+
/**
|
|
297
|
+
* List of string arguments passed to the Node.js executable.
|
|
298
|
+
* @default process.execArgv
|
|
299
|
+
*/
|
|
300
|
+
execArgv?: string[] | undefined;
|
|
301
|
+
/**
|
|
302
|
+
* File path to worker file.
|
|
303
|
+
* @default process.argv[1]
|
|
304
|
+
*/
|
|
305
|
+
exec?: string | undefined;
|
|
306
|
+
/**
|
|
307
|
+
* String arguments passed to worker.
|
|
308
|
+
* @default process.argv.slice(2)
|
|
309
|
+
*/
|
|
310
|
+
args?: readonly string[] | undefined;
|
|
311
|
+
/**
|
|
312
|
+
* Whether or not to send output to parent's stdio.
|
|
313
|
+
* @default false
|
|
314
|
+
*/
|
|
315
|
+
silent?: boolean | undefined;
|
|
316
|
+
/**
|
|
317
|
+
* Configures the stdio of forked processes. Because the cluster module relies on IPC to function, this configuration must
|
|
318
|
+
* contain an `'ipc'` entry. When this option is provided, it overrides `silent`. See [`child_prcess.spawn()`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#child_processspawncommand-args-options)'s
|
|
319
|
+
* [`stdio`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#optionsstdio).
|
|
320
|
+
*/
|
|
321
|
+
stdio?: any[] | undefined;
|
|
322
|
+
/**
|
|
323
|
+
* Sets the user identity of the process. (See [`setuid(2)`](https://man7.org/linux/man-pages/man2/setuid.2.html).)
|
|
324
|
+
*/
|
|
325
|
+
uid?: number | undefined;
|
|
326
|
+
/**
|
|
327
|
+
* Sets the group identity of the process. (See [`setgid(2)`](https://man7.org/linux/man-pages/man2/setgid.2.html).)
|
|
328
|
+
*/
|
|
329
|
+
gid?: number | undefined;
|
|
330
|
+
/**
|
|
331
|
+
* Sets inspector port of worker. This can be a number, or a function that takes no arguments and returns a number.
|
|
332
|
+
* By default each worker gets its own port, incremented from the primary's `process.debugPort`.
|
|
333
|
+
*/
|
|
334
|
+
inspectPort?: number | (() => number) | undefined;
|
|
335
|
+
/**
|
|
336
|
+
* Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`.
|
|
337
|
+
* See [Advanced serialization for `child_process`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#advanced-serialization) for more details.
|
|
338
|
+
* @default false
|
|
339
|
+
*/
|
|
340
|
+
serialization?: "json" | "advanced" | undefined;
|
|
341
|
+
/**
|
|
342
|
+
* Current working directory of the worker process.
|
|
343
|
+
* @default undefined (inherits from parent process)
|
|
344
|
+
*/
|
|
345
|
+
cwd?: string | undefined;
|
|
346
|
+
/**
|
|
347
|
+
* Hide the forked processes console window that would normally be created on Windows systems.
|
|
348
|
+
* @default false
|
|
349
|
+
*/
|
|
350
|
+
windowsHide?: boolean | undefined;
|
|
351
|
+
}
|
|
352
|
+
interface Address {
|
|
353
|
+
address: string;
|
|
354
|
+
port: number;
|
|
355
|
+
/**
|
|
356
|
+
* The `addressType` is one of:
|
|
357
|
+
*
|
|
358
|
+
* * `4` (TCPv4)
|
|
359
|
+
* * `6` (TCPv6)
|
|
360
|
+
* * `-1` (Unix domain socket)
|
|
361
|
+
* * `'udp4'` or `'udp6'` (UDPv4 or UDPv6)
|
|
362
|
+
*/
|
|
363
|
+
addressType: 4 | 6 | -1 | "udp4" | "udp6";
|
|
364
|
+
}
|
|
365
|
+
interface ClusterEventMap {
|
|
366
|
+
"disconnect": [worker: Worker];
|
|
367
|
+
"exit": [worker: Worker, code: number, signal: string];
|
|
368
|
+
"fork": [worker: Worker];
|
|
369
|
+
"listening": [worker: Worker, address: Address];
|
|
370
|
+
"message": [worker: Worker, message: any, handle: child_process.SendHandle];
|
|
371
|
+
"online": [worker: Worker];
|
|
372
|
+
"setup": [settings: ClusterSettings];
|
|
373
|
+
}
|
|
374
|
+
interface Cluster extends InternalEventEmitter<ClusterEventMap> {
|
|
375
|
+
/**
|
|
376
|
+
* A `Worker` object contains all public information and method about a worker.
|
|
377
|
+
* In the primary it can be obtained using `cluster.workers`. In a worker
|
|
378
|
+
* it can be obtained using `cluster.worker`.
|
|
379
|
+
* @since v0.7.0
|
|
380
|
+
*/
|
|
381
|
+
Worker: typeof Worker;
|
|
382
|
+
disconnect(callback?: () => void): void;
|
|
383
|
+
/**
|
|
384
|
+
* Spawn a new worker process.
|
|
385
|
+
*
|
|
386
|
+
* This can only be called from the primary process.
|
|
387
|
+
* @param env Key/value pairs to add to worker process environment.
|
|
388
|
+
* @since v0.6.0
|
|
389
|
+
*/
|
|
390
|
+
fork(env?: any): Worker;
|
|
391
|
+
/** @deprecated since v16.0.0 - use isPrimary. */
|
|
392
|
+
readonly isMaster: boolean;
|
|
393
|
+
/**
|
|
394
|
+
* True if the process is a primary. This is determined by the `process.env.NODE_UNIQUE_ID`. If `process.env.NODE_UNIQUE_ID`
|
|
395
|
+
* is undefined, then `isPrimary` is `true`.
|
|
396
|
+
* @since v16.0.0
|
|
397
|
+
*/
|
|
398
|
+
readonly isPrimary: boolean;
|
|
399
|
+
/**
|
|
400
|
+
* True if the process is not a primary (it is the negation of `cluster.isPrimary`).
|
|
401
|
+
* @since v0.6.0
|
|
402
|
+
*/
|
|
403
|
+
readonly isWorker: boolean;
|
|
404
|
+
/**
|
|
405
|
+
* The scheduling policy, either `cluster.SCHED_RR` for round-robin or `cluster.SCHED_NONE` to leave it to the operating system. This is a
|
|
406
|
+
* global setting and effectively frozen once either the first worker is spawned, or [`.setupPrimary()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clustersetupprimarysettings)
|
|
407
|
+
* is called, whichever comes first.
|
|
408
|
+
*
|
|
409
|
+
* `SCHED_RR` is the default on all operating systems except Windows. Windows will change to `SCHED_RR` once libuv is able to effectively distribute
|
|
410
|
+
* IOCP handles without incurring a large performance hit.
|
|
411
|
+
*
|
|
412
|
+
* `cluster.schedulingPolicy` can also be set through the `NODE_CLUSTER_SCHED_POLICY` environment variable. Valid values are `'rr'` and `'none'`.
|
|
413
|
+
* @since v0.11.2
|
|
414
|
+
*/
|
|
415
|
+
schedulingPolicy: number;
|
|
416
|
+
/**
|
|
417
|
+
* After calling [`.setupPrimary()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clustersetupprimarysettings)
|
|
418
|
+
* (or [`.fork()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clusterforkenv)) this settings object will contain
|
|
419
|
+
* the settings, including the default values.
|
|
420
|
+
*
|
|
421
|
+
* This object is not intended to be changed or set manually.
|
|
422
|
+
* @since v0.7.1
|
|
423
|
+
*/
|
|
424
|
+
readonly settings: ClusterSettings;
|
|
425
|
+
/** @deprecated since v16.0.0 - use [`.setupPrimary()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clustersetupprimarysettings) instead. */
|
|
426
|
+
setupMaster(settings?: ClusterSettings): void;
|
|
427
|
+
/**
|
|
428
|
+
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in `cluster.settings`.
|
|
429
|
+
*
|
|
430
|
+
* Any settings changes only affect future calls to [`.fork()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clusterforkenv)
|
|
431
|
+
* and have no effect on workers that are already running.
|
|
432
|
+
*
|
|
433
|
+
* The only attribute of a worker that cannot be set via `.setupPrimary()` is the `env` passed to
|
|
434
|
+
* [`.fork()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clusterforkenv).
|
|
435
|
+
*
|
|
436
|
+
* The defaults above apply to the first call only; the defaults for later calls are the current values at the time of
|
|
437
|
+
* `cluster.setupPrimary()` is called.
|
|
438
|
+
*
|
|
439
|
+
* ```js
|
|
440
|
+
* import cluster from 'node:cluster';
|
|
441
|
+
*
|
|
442
|
+
* cluster.setupPrimary({
|
|
443
|
+
* exec: 'worker.js',
|
|
444
|
+
* args: ['--use', 'https'],
|
|
445
|
+
* silent: true,
|
|
446
|
+
* });
|
|
447
|
+
* cluster.fork(); // https worker
|
|
448
|
+
* cluster.setupPrimary({
|
|
449
|
+
* exec: 'worker.js',
|
|
450
|
+
* args: ['--use', 'http'],
|
|
451
|
+
* });
|
|
452
|
+
* cluster.fork(); // http worker
|
|
453
|
+
* ```
|
|
454
|
+
*
|
|
455
|
+
* This can only be called from the primary process.
|
|
456
|
+
* @since v16.0.0
|
|
457
|
+
*/
|
|
458
|
+
setupPrimary(settings?: ClusterSettings): void;
|
|
459
|
+
/**
|
|
460
|
+
* A reference to the current worker object. Not available in the primary process.
|
|
461
|
+
*
|
|
462
|
+
* ```js
|
|
463
|
+
* import cluster from 'node:cluster';
|
|
464
|
+
*
|
|
465
|
+
* if (cluster.isPrimary) {
|
|
466
|
+
* console.log('I am primary');
|
|
467
|
+
* cluster.fork();
|
|
468
|
+
* cluster.fork();
|
|
469
|
+
* } else if (cluster.isWorker) {
|
|
470
|
+
* console.log(`I am worker #${cluster.worker.id}`);
|
|
471
|
+
* }
|
|
472
|
+
* ```
|
|
473
|
+
* @since v0.7.0
|
|
474
|
+
*/
|
|
475
|
+
readonly worker?: Worker;
|
|
476
|
+
/**
|
|
477
|
+
* A hash that stores the active worker objects, keyed by `id` field. This makes it easy to loop through all the workers. It is only available in the primary process.
|
|
478
|
+
*
|
|
479
|
+
* A worker is removed from `cluster.workers` after the worker has disconnected _and_ exited. The order between these two events cannot be determined in advance. However, it
|
|
480
|
+
* is guaranteed that the removal from the `cluster.workers` list happens before the last `'disconnect'` or `'exit'` event is emitted.
|
|
481
|
+
*
|
|
482
|
+
* ```js
|
|
483
|
+
* import cluster from 'node:cluster';
|
|
484
|
+
*
|
|
485
|
+
* for (const worker of Object.values(cluster.workers)) {
|
|
486
|
+
* worker.send('big announcement to all workers');
|
|
487
|
+
* }
|
|
488
|
+
* ```
|
|
489
|
+
* @since v0.7.0
|
|
490
|
+
*/
|
|
491
|
+
readonly workers?: NodeJS.Dict<Worker>;
|
|
492
|
+
readonly SCHED_NONE: number;
|
|
493
|
+
readonly SCHED_RR: number;
|
|
494
|
+
}
|
|
588
495
|
}
|
|
589
|
-
|
|
590
|
-
export
|
|
496
|
+
var cluster: cluster.Cluster;
|
|
497
|
+
export = cluster;
|
|
591
498
|
}
|