@idlebox/stripe-node-types 24.0.14-patch.0 → 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 +113 -1
- package/assert.d.ts +162 -248
- package/async_hooks.d.ts +20 -5
- package/buffer.buffer.d.ts +24 -6
- package/buffer.d.ts +63 -168
- package/child_process.d.ts +117 -223
- package/cluster.d.ts +251 -329
- package/compatibility/iterators.d.ts +15 -0
- package/console.d.ts +60 -346
- package/constants.d.ts +15 -1
- package/crypto.d.ts +713 -1149
- package/dgram.d.ts +30 -50
- package/diagnostics_channel.d.ts +16 -3
- package/dns/promises.d.ts +15 -0
- package/dns.d.ts +150 -131
- package/domain.d.ts +25 -14
- package/events.d.ts +858 -719
- package/fs/promises.d.ts +117 -53
- package/fs.d.ts +729 -484
- package/globals.d.ts +142 -344
- package/globals.typedarray.d.ts +94 -0
- package/http.d.ts +358 -246
- package/http2.d.ts +578 -711
- package/https.d.ts +85 -216
- package/index.d.ts +39 -3
- package/inspector/promises.d.ts +54 -0
- package/inspector.d.ts +180 -3936
- package/inspector.generated.d.ts +4242 -0
- package/module.d.ts +60 -95
- package/my-shim.d.ts +15 -0
- package/net.d.ts +102 -186
- package/os.d.ts +32 -6
- package/package.json +3 -8
- package/path/posix.d.ts +20 -0
- package/path/win32.d.ts +20 -0
- package/path.d.ts +132 -122
- package/perf_hooks.d.ts +310 -644
- package/process.d.ts +192 -138
- package/punycode.d.ts +17 -2
- package/querystring.d.ts +16 -1
- package/quic.d.ts +926 -0
- package/readline/promises.d.ts +16 -1
- package/readline.d.ts +80 -118
- package/repl.d.ts +98 -96
- package/sea.d.ts +25 -1
- package/sqlite.d.ts +277 -13
- package/stream/consumers.d.ts +22 -7
- package/stream/promises.d.ts +148 -12
- package/stream/web.d.ts +187 -494
- package/stream.d.ts +608 -490
- package/string_decoder.d.ts +18 -3
- package/test/reporters.d.ts +112 -0
- package/test.d.ts +238 -199
- package/timers/promises.d.ts +16 -1
- package/timers.d.ts +16 -129
- package/tls.d.ts +163 -163
- package/trace_events.d.ts +21 -6
- package/ts5.6/buffer.buffer.d.ts +25 -8
- package/ts5.6/compatibility/float16array.d.ts +15 -0
- package/ts5.6/globals.typedarray.d.ts +31 -0
- package/ts5.6/index.d.ts +39 -3
- package/ts5.7/compatibility/float16array.d.ts +15 -0
- package/ts5.7/index.d.ts +39 -3
- package/tty.d.ts +70 -13
- package/undici-types/agent.d.ts +20 -4
- package/undici-types/api.d.ts +15 -0
- package/undici-types/balanced-pool.d.ts +15 -0
- package/undici-types/cache-interceptor.d.ts +15 -0
- package/undici-types/cache.d.ts +15 -0
- package/undici-types/client-stats.d.ts +31 -0
- package/undici-types/client.d.ts +21 -5
- package/undici-types/connector.d.ts +15 -0
- package/undici-types/content-type.d.ts +15 -0
- package/undici-types/cookies.d.ts +15 -0
- package/undici-types/diagnostics-channel.d.ts +24 -1
- package/undici-types/dispatcher.d.ts +18 -8
- package/undici-types/env-http-proxy-agent.d.ts +17 -1
- package/undici-types/errors.d.ts +20 -15
- package/undici-types/eventsource.d.ts +24 -4
- package/undici-types/fetch.d.ts +16 -0
- package/undici-types/formdata.d.ts +15 -0
- package/undici-types/global-dispatcher.d.ts +15 -0
- package/undici-types/global-origin.d.ts +15 -0
- package/undici-types/h2c-client.d.ts +15 -2
- package/undici-types/handlers.d.ts +16 -1
- package/undici-types/header.d.ts +15 -0
- package/undici-types/index.d.ts +21 -1
- package/undici-types/interceptors.d.ts +20 -0
- package/undici-types/mock-agent.d.ts +18 -0
- package/undici-types/mock-call-history.d.ts +15 -0
- package/undici-types/mock-client.d.ts +17 -0
- package/undici-types/mock-errors.d.ts +15 -0
- package/undici-types/mock-interceptor.d.ts +17 -1
- package/undici-types/mock-pool.d.ts +17 -0
- package/undici-types/package.json +1 -1
- package/undici-types/patch.d.ts +15 -0
- package/undici-types/pool-stats.d.ts +15 -0
- package/undici-types/pool.d.ts +17 -0
- package/undici-types/proxy-agent.d.ts +16 -0
- package/undici-types/readable.d.ts +15 -0
- package/undici-types/retry-agent.d.ts +15 -0
- package/undici-types/retry-handler.d.ts +24 -0
- package/undici-types/snapshot-agent.d.ts +125 -0
- package/undici-types/util.d.ts +15 -0
- package/undici-types/utility.d.ts +15 -0
- package/undici-types/webidl.d.ts +126 -36
- package/undici-types/websocket.d.ts +18 -1
- package/url.d.ts +107 -587
- package/util/types.d.ts +571 -0
- package/util.d.ts +158 -792
- package/v8.d.ts +82 -7
- package/vm.d.ts +267 -108
- package/wasi.d.ts +38 -2
- package/web-globals/abortcontroller.d.ts +75 -0
- package/web-globals/blob.d.ts +39 -0
- package/web-globals/console.d.ts +25 -0
- 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} +72 -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 +306 -349
- package/zlib.d.ts +59 -94
- package/ts5.1/compatibility/disposable.d.ts +0 -13
- package/ts5.1/index.d.ts +0 -100
package/cluster.d.ts
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
// biome-ignore-all lint: generated file
|
|
2
|
+
// biome-ignore-all assist: generated file
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
|
|
6
|
+
/******************************************************************************
|
|
7
|
+
* GENERATED FILE, DO NOT MODIFY
|
|
8
|
+
* 这是生成的文件,千万不要修改
|
|
9
|
+
*
|
|
10
|
+
* @build-script/codegen - The Simple Code Generater
|
|
11
|
+
* https://github.com/GongT/baobao
|
|
12
|
+
*
|
|
13
|
+
******************************************************************************/
|
|
14
|
+
|
|
15
|
+
|
|
1
16
|
/**
|
|
2
17
|
* Clusters of Node.js processes can be used to run multiple instances of Node.js
|
|
3
18
|
* that can distribute workloads among their application threads. When process isolation
|
|
4
|
-
* 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)
|
|
5
20
|
* module instead, which allows running multiple application threads within a single Node.js instance.
|
|
6
21
|
*
|
|
7
22
|
* The cluster module allows easy creation of child processes that all share
|
|
@@ -50,91 +65,14 @@
|
|
|
50
65
|
* ```
|
|
51
66
|
*
|
|
52
67
|
* 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/
|
|
68
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/cluster.js)
|
|
54
69
|
*/
|
|
55
70
|
|
|
56
71
|
declare module "node:cluster" {
|
|
57
|
-
import * as
|
|
58
|
-
import EventEmitter
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export interface ClusterSettings {
|
|
62
|
-
/**
|
|
63
|
-
* List of string arguments passed to the Node.js executable.
|
|
64
|
-
* @default process.execArgv
|
|
65
|
-
*/
|
|
66
|
-
execArgv?: string[] | undefined;
|
|
67
|
-
/**
|
|
68
|
-
* File path to worker file.
|
|
69
|
-
* @default process.argv[1]
|
|
70
|
-
*/
|
|
71
|
-
exec?: string | undefined;
|
|
72
|
-
/**
|
|
73
|
-
* String arguments passed to worker.
|
|
74
|
-
* @default process.argv.slice(2)
|
|
75
|
-
*/
|
|
76
|
-
args?: string[] | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Whether or not to send output to parent's stdio.
|
|
79
|
-
* @default false
|
|
80
|
-
*/
|
|
81
|
-
silent?: boolean | undefined;
|
|
82
|
-
/**
|
|
83
|
-
* Configures the stdio of forked processes. Because the cluster module relies on IPC to function, this configuration must
|
|
84
|
-
* 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
|
|
85
|
-
* [`stdio`](https://nodejs.org/docs/latest-v24.x/api/child_process.html#optionsstdio).
|
|
86
|
-
*/
|
|
87
|
-
stdio?: any[] | undefined;
|
|
88
|
-
/**
|
|
89
|
-
* Sets the user identity of the process. (See [`setuid(2)`](https://man7.org/linux/man-pages/man2/setuid.2.html).)
|
|
90
|
-
*/
|
|
91
|
-
uid?: number | undefined;
|
|
92
|
-
/**
|
|
93
|
-
* Sets the group identity of the process. (See [`setgid(2)`](https://man7.org/linux/man-pages/man2/setgid.2.html).)
|
|
94
|
-
*/
|
|
95
|
-
gid?: number | undefined;
|
|
96
|
-
/**
|
|
97
|
-
* Sets inspector port of worker. This can be a number, or a function that takes no arguments and returns a number.
|
|
98
|
-
* By default each worker gets its own port, incremented from the primary's `process.debugPort`.
|
|
99
|
-
*/
|
|
100
|
-
inspectPort?: number | (() => number) | undefined;
|
|
101
|
-
/**
|
|
102
|
-
* Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`.
|
|
103
|
-
* See [Advanced serialization for `child_process`](https://nodejs.org/docs/latest-v24.x/api/child_process.html#advanced-serialization) for more details.
|
|
104
|
-
* @default false
|
|
105
|
-
*/
|
|
106
|
-
serialization?: SerializationType | undefined;
|
|
107
|
-
/**
|
|
108
|
-
* Current working directory of the worker process.
|
|
109
|
-
* @default undefined (inherits from parent process)
|
|
110
|
-
*/
|
|
111
|
-
cwd?: string | undefined;
|
|
112
|
-
/**
|
|
113
|
-
* Hide the forked processes console window that would normally be created on Windows systems.
|
|
114
|
-
* @default false
|
|
115
|
-
*/
|
|
116
|
-
windowsHide?: boolean | undefined;
|
|
117
|
-
}
|
|
118
|
-
export interface Address {
|
|
119
|
-
address: string;
|
|
120
|
-
port: number;
|
|
121
|
-
/**
|
|
122
|
-
* The `addressType` is one of:
|
|
123
|
-
*
|
|
124
|
-
* * `4` (TCPv4)
|
|
125
|
-
* * `6` (TCPv6)
|
|
126
|
-
* * `-1` (Unix domain socket)
|
|
127
|
-
* * `'udp4'` or `'udp6'` (UDPv4 or UDPv6)
|
|
128
|
-
*/
|
|
129
|
-
addressType: 4 | 6 | -1 | "udp4" | "udp6";
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* A `Worker` object contains all public information and method about a worker.
|
|
133
|
-
* In the primary it can be obtained using `cluster.workers`. In a worker
|
|
134
|
-
* it can be obtained using `cluster.worker`.
|
|
135
|
-
* @since v0.7.0
|
|
136
|
-
*/
|
|
137
|
-
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);
|
|
138
76
|
/**
|
|
139
77
|
* Each new worker is given its own unique id, this id is stored in the `id`.
|
|
140
78
|
*
|
|
@@ -143,21 +81,21 @@ declare module "node:cluster" {
|
|
|
143
81
|
*/
|
|
144
82
|
id: number;
|
|
145
83
|
/**
|
|
146
|
-
* 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
|
|
147
85
|
* from this function is stored as `.process`. In a worker, the global `process` is stored.
|
|
148
86
|
*
|
|
149
|
-
* 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).
|
|
150
88
|
*
|
|
151
89
|
* Workers will call `process.exit(0)` if the `'disconnect'` event occurs
|
|
152
90
|
* on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
|
|
153
91
|
* accidental disconnection.
|
|
154
92
|
* @since v0.7.0
|
|
155
93
|
*/
|
|
156
|
-
process:
|
|
94
|
+
process: child_process.ChildProcess;
|
|
157
95
|
/**
|
|
158
96
|
* Send a message to a worker or primary, optionally with a handle.
|
|
159
97
|
*
|
|
160
|
-
* 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).
|
|
161
99
|
*
|
|
162
100
|
* In a worker, this sends a message to the primary. It is identical to `process.send()`.
|
|
163
101
|
*
|
|
@@ -177,16 +115,16 @@ declare module "node:cluster" {
|
|
|
177
115
|
* @since v0.7.0
|
|
178
116
|
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles.
|
|
179
117
|
*/
|
|
180
|
-
send(message:
|
|
118
|
+
send(message: child_process.Serializable, callback?: (error: Error | null) => void): boolean;
|
|
181
119
|
send(
|
|
182
|
-
message:
|
|
183
|
-
sendHandle:
|
|
120
|
+
message: child_process.Serializable,
|
|
121
|
+
sendHandle: child_process.SendHandle,
|
|
184
122
|
callback?: (error: Error | null) => void,
|
|
185
123
|
): boolean;
|
|
186
124
|
send(
|
|
187
|
-
message:
|
|
188
|
-
sendHandle:
|
|
189
|
-
options?:
|
|
125
|
+
message: child_process.Serializable,
|
|
126
|
+
sendHandle: child_process.SendHandle,
|
|
127
|
+
options?: child_process.MessageOptions,
|
|
190
128
|
callback?: (error: Error | null) => void,
|
|
191
129
|
): boolean;
|
|
192
130
|
/**
|
|
@@ -199,7 +137,7 @@ declare module "node:cluster" {
|
|
|
199
137
|
* This method is aliased as `worker.destroy()` for backwards compatibility.
|
|
200
138
|
*
|
|
201
139
|
* In a worker, `process.kill()` exists, but it is not this function;
|
|
202
|
-
* it is [`kill()`](https://nodejs.org/docs/latest-
|
|
140
|
+
* it is [`kill()`](https://nodejs.org/docs/latest-v25.x/api/process.html#processkillpid-signal).
|
|
203
141
|
* @since v0.9.12
|
|
204
142
|
* @param [signal='SIGTERM'] Name of the kill signal to send to the worker process.
|
|
205
143
|
*/
|
|
@@ -336,241 +274,225 @@ declare module "node:cluster" {
|
|
|
336
274
|
* @since v6.0.0
|
|
337
275
|
*/
|
|
338
276
|
exitedAfterDisconnect: boolean;
|
|
339
|
-
/**
|
|
340
|
-
* events.EventEmitter
|
|
341
|
-
* 1. disconnect
|
|
342
|
-
* 2. error
|
|
343
|
-
* 3. exit
|
|
344
|
-
* 4. listening
|
|
345
|
-
* 5. message
|
|
346
|
-
* 6. online
|
|
347
|
-
*/
|
|
348
|
-
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
349
|
-
addListener(event: "disconnect", listener: () => void): this;
|
|
350
|
-
addListener(event: "error", listener: (error: Error) => void): this;
|
|
351
|
-
addListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
|
352
|
-
addListener(event: "listening", listener: (address: Address) => void): this;
|
|
353
|
-
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.
|
|
354
|
-
addListener(event: "online", listener: () => void): this;
|
|
355
|
-
emit(event: string | symbol, ...args: any[]): boolean;
|
|
356
|
-
emit(event: "disconnect"): boolean;
|
|
357
|
-
emit(event: "error", error: Error): boolean;
|
|
358
|
-
emit(event: "exit", code: number, signal: string): boolean;
|
|
359
|
-
emit(event: "listening", address: Address): boolean;
|
|
360
|
-
emit(event: "message", message: any, handle: net.Socket | net.Server): boolean;
|
|
361
|
-
emit(event: "online"): boolean;
|
|
362
|
-
on(event: string, listener: (...args: any[]) => void): this;
|
|
363
|
-
on(event: "disconnect", listener: () => void): this;
|
|
364
|
-
on(event: "error", listener: (error: Error) => void): this;
|
|
365
|
-
on(event: "exit", listener: (code: number, signal: string) => void): this;
|
|
366
|
-
on(event: "listening", listener: (address: Address) => void): this;
|
|
367
|
-
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.
|
|
368
|
-
on(event: "online", listener: () => void): this;
|
|
369
|
-
once(event: string, listener: (...args: any[]) => void): this;
|
|
370
|
-
once(event: "disconnect", listener: () => void): this;
|
|
371
|
-
once(event: "error", listener: (error: Error) => void): this;
|
|
372
|
-
once(event: "exit", listener: (code: number, signal: string) => void): this;
|
|
373
|
-
once(event: "listening", listener: (address: Address) => void): this;
|
|
374
|
-
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.
|
|
375
|
-
once(event: "online", listener: () => void): this;
|
|
376
|
-
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
377
|
-
prependListener(event: "disconnect", listener: () => void): this;
|
|
378
|
-
prependListener(event: "error", listener: (error: Error) => void): this;
|
|
379
|
-
prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
|
380
|
-
prependListener(event: "listening", listener: (address: Address) => void): this;
|
|
381
|
-
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.
|
|
382
|
-
prependListener(event: "online", listener: () => void): this;
|
|
383
|
-
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
|
384
|
-
prependOnceListener(event: "disconnect", listener: () => void): this;
|
|
385
|
-
prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
|
386
|
-
prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
|
387
|
-
prependOnceListener(event: "listening", listener: (address: Address) => void): this;
|
|
388
|
-
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.
|
|
389
|
-
prependOnceListener(event: "online", listener: () => void): this;
|
|
390
277
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
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
|
-
|
|
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
|
+
}
|
|
573
495
|
}
|
|
574
|
-
|
|
575
|
-
export
|
|
496
|
+
var cluster: cluster.Cluster;
|
|
497
|
+
export = cluster;
|
|
576
498
|
}
|