@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.
Files changed (134) hide show
  1. package/README.md +1 -1
  2. package/assert/strict.d.ts +113 -1
  3. package/assert.d.ts +162 -248
  4. package/async_hooks.d.ts +20 -5
  5. package/buffer.buffer.d.ts +24 -6
  6. package/buffer.d.ts +63 -168
  7. package/child_process.d.ts +117 -223
  8. package/cluster.d.ts +251 -329
  9. package/compatibility/iterators.d.ts +15 -0
  10. package/console.d.ts +60 -346
  11. package/constants.d.ts +15 -1
  12. package/crypto.d.ts +713 -1149
  13. package/dgram.d.ts +30 -50
  14. package/diagnostics_channel.d.ts +16 -3
  15. package/dns/promises.d.ts +15 -0
  16. package/dns.d.ts +150 -131
  17. package/domain.d.ts +25 -14
  18. package/events.d.ts +858 -719
  19. package/fs/promises.d.ts +117 -53
  20. package/fs.d.ts +729 -484
  21. package/globals.d.ts +142 -344
  22. package/globals.typedarray.d.ts +94 -0
  23. package/http.d.ts +358 -246
  24. package/http2.d.ts +578 -711
  25. package/https.d.ts +85 -216
  26. package/index.d.ts +39 -3
  27. package/inspector/promises.d.ts +54 -0
  28. package/inspector.d.ts +180 -3936
  29. package/inspector.generated.d.ts +4242 -0
  30. package/module.d.ts +60 -95
  31. package/my-shim.d.ts +15 -0
  32. package/net.d.ts +102 -186
  33. package/os.d.ts +32 -6
  34. package/package.json +3 -8
  35. package/path/posix.d.ts +20 -0
  36. package/path/win32.d.ts +20 -0
  37. package/path.d.ts +132 -122
  38. package/perf_hooks.d.ts +310 -644
  39. package/process.d.ts +192 -138
  40. package/punycode.d.ts +17 -2
  41. package/querystring.d.ts +16 -1
  42. package/quic.d.ts +926 -0
  43. package/readline/promises.d.ts +16 -1
  44. package/readline.d.ts +80 -118
  45. package/repl.d.ts +98 -96
  46. package/sea.d.ts +25 -1
  47. package/sqlite.d.ts +277 -13
  48. package/stream/consumers.d.ts +22 -7
  49. package/stream/promises.d.ts +148 -12
  50. package/stream/web.d.ts +187 -494
  51. package/stream.d.ts +608 -490
  52. package/string_decoder.d.ts +18 -3
  53. package/test/reporters.d.ts +112 -0
  54. package/test.d.ts +238 -199
  55. package/timers/promises.d.ts +16 -1
  56. package/timers.d.ts +16 -129
  57. package/tls.d.ts +163 -163
  58. package/trace_events.d.ts +21 -6
  59. package/ts5.6/buffer.buffer.d.ts +25 -8
  60. package/ts5.6/compatibility/float16array.d.ts +15 -0
  61. package/ts5.6/globals.typedarray.d.ts +31 -0
  62. package/ts5.6/index.d.ts +39 -3
  63. package/ts5.7/compatibility/float16array.d.ts +15 -0
  64. package/ts5.7/index.d.ts +39 -3
  65. package/tty.d.ts +70 -13
  66. package/undici-types/agent.d.ts +20 -4
  67. package/undici-types/api.d.ts +15 -0
  68. package/undici-types/balanced-pool.d.ts +15 -0
  69. package/undici-types/cache-interceptor.d.ts +15 -0
  70. package/undici-types/cache.d.ts +15 -0
  71. package/undici-types/client-stats.d.ts +31 -0
  72. package/undici-types/client.d.ts +21 -5
  73. package/undici-types/connector.d.ts +15 -0
  74. package/undici-types/content-type.d.ts +15 -0
  75. package/undici-types/cookies.d.ts +15 -0
  76. package/undici-types/diagnostics-channel.d.ts +24 -1
  77. package/undici-types/dispatcher.d.ts +18 -8
  78. package/undici-types/env-http-proxy-agent.d.ts +17 -1
  79. package/undici-types/errors.d.ts +20 -15
  80. package/undici-types/eventsource.d.ts +24 -4
  81. package/undici-types/fetch.d.ts +16 -0
  82. package/undici-types/formdata.d.ts +15 -0
  83. package/undici-types/global-dispatcher.d.ts +15 -0
  84. package/undici-types/global-origin.d.ts +15 -0
  85. package/undici-types/h2c-client.d.ts +15 -2
  86. package/undici-types/handlers.d.ts +16 -1
  87. package/undici-types/header.d.ts +15 -0
  88. package/undici-types/index.d.ts +21 -1
  89. package/undici-types/interceptors.d.ts +20 -0
  90. package/undici-types/mock-agent.d.ts +18 -0
  91. package/undici-types/mock-call-history.d.ts +15 -0
  92. package/undici-types/mock-client.d.ts +17 -0
  93. package/undici-types/mock-errors.d.ts +15 -0
  94. package/undici-types/mock-interceptor.d.ts +17 -1
  95. package/undici-types/mock-pool.d.ts +17 -0
  96. package/undici-types/package.json +1 -1
  97. package/undici-types/patch.d.ts +15 -0
  98. package/undici-types/pool-stats.d.ts +15 -0
  99. package/undici-types/pool.d.ts +17 -0
  100. package/undici-types/proxy-agent.d.ts +16 -0
  101. package/undici-types/readable.d.ts +15 -0
  102. package/undici-types/retry-agent.d.ts +15 -0
  103. package/undici-types/retry-handler.d.ts +24 -0
  104. package/undici-types/snapshot-agent.d.ts +125 -0
  105. package/undici-types/util.d.ts +15 -0
  106. package/undici-types/utility.d.ts +15 -0
  107. package/undici-types/webidl.d.ts +126 -36
  108. package/undici-types/websocket.d.ts +18 -1
  109. package/url.d.ts +107 -587
  110. package/util/types.d.ts +571 -0
  111. package/util.d.ts +158 -792
  112. package/v8.d.ts +82 -7
  113. package/vm.d.ts +267 -108
  114. package/wasi.d.ts +38 -2
  115. package/web-globals/abortcontroller.d.ts +75 -0
  116. package/web-globals/blob.d.ts +39 -0
  117. package/web-globals/console.d.ts +25 -0
  118. package/web-globals/crypto.d.ts +55 -0
  119. package/web-globals/domexception.d.ts +84 -0
  120. package/web-globals/encoding.d.ts +27 -0
  121. package/{dom-events.d.ts → web-globals/events.d.ts} +72 -50
  122. package/web-globals/fetch.d.ts +70 -0
  123. package/web-globals/importmeta.d.ts +29 -0
  124. package/web-globals/messaging.d.ts +39 -0
  125. package/web-globals/navigator.d.ts +41 -0
  126. package/web-globals/performance.d.ts +61 -0
  127. package/web-globals/storage.d.ts +40 -0
  128. package/web-globals/streams.d.ts +131 -0
  129. package/web-globals/timers.d.ts +60 -0
  130. package/web-globals/url.d.ts +40 -0
  131. package/worker_threads.d.ts +306 -349
  132. package/zlib.d.ts +59 -94
  133. package/ts5.1/compatibility/disposable.d.ts +0 -13
  134. 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-v24.x/api/worker_threads.html)
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/v24.x/lib/cluster.js)
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 child from 'node:child_process';
58
- import EventEmitter = require('node:events');
59
- import * as net from 'node:net';
60
- type SerializationType = "json" | "advanced";
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-v24.x/api/child_process.html#child_processforkmodulepath-args-options), the returned object
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-v24.x/api/child_process.html#child_processforkmodulepath-args-options).
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: child.ChildProcess;
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-v24.x/api/child_process.html#subprocesssendmessage-sendhandle-options-callback).
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: child.Serializable, callback?: (error: Error | null) => void): boolean;
118
+ send(message: child_process.Serializable, callback?: (error: Error | null) => void): boolean;
181
119
  send(
182
- message: child.Serializable,
183
- sendHandle: child.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: child.Serializable,
188
- sendHandle: child.SendHandle,
189
- options?: child.MessageOptions,
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-v24.x/api/process.html#processkillpid-signal).
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
- export interface Cluster extends EventEmitter {
392
- disconnect(callback?: () => void): void;
393
- /**
394
- * Spawn a new worker process.
395
- *
396
- * This can only be called from the primary process.
397
- * @param env Key/value pairs to add to worker process environment.
398
- * @since v0.6.0
399
- */
400
- fork(env?: any): Worker;
401
- /** @deprecated since v16.0.0 - use isPrimary. */
402
- readonly isMaster: boolean;
403
- /**
404
- * True if the process is a primary. This is determined by the `process.env.NODE_UNIQUE_ID`. If `process.env.NODE_UNIQUE_ID`
405
- * is undefined, then `isPrimary` is `true`.
406
- * @since v16.0.0
407
- */
408
- readonly isPrimary: boolean;
409
- /**
410
- * True if the process is not a primary (it is the negation of `cluster.isPrimary`).
411
- * @since v0.6.0
412
- */
413
- readonly isWorker: boolean;
414
- /**
415
- * The scheduling policy, either `cluster.SCHED_RR` for round-robin or `cluster.SCHED_NONE` to leave it to the operating system. This is a
416
- * global setting and effectively frozen once either the first worker is spawned, or [`.setupPrimary()`](https://nodejs.org/docs/latest-v24.x/api/cluster.html#clustersetupprimarysettings)
417
- * is called, whichever comes first.
418
- *
419
- * `SCHED_RR` is the default on all operating systems except Windows. Windows will change to `SCHED_RR` once libuv is able to effectively distribute
420
- * IOCP handles without incurring a large performance hit.
421
- *
422
- * `cluster.schedulingPolicy` can also be set through the `NODE_CLUSTER_SCHED_POLICY` environment variable. Valid values are `'rr'` and `'none'`.
423
- * @since v0.11.2
424
- */
425
- schedulingPolicy: number;
426
- /**
427
- * After calling [`.setupPrimary()`](https://nodejs.org/docs/latest-v24.x/api/cluster.html#clustersetupprimarysettings)
428
- * (or [`.fork()`](https://nodejs.org/docs/latest-v24.x/api/cluster.html#clusterforkenv)) this settings object will contain
429
- * the settings, including the default values.
430
- *
431
- * This object is not intended to be changed or set manually.
432
- * @since v0.7.1
433
- */
434
- readonly settings: ClusterSettings;
435
- /** @deprecated since v16.0.0 - use [`.setupPrimary()`](https://nodejs.org/docs/latest-v24.x/api/cluster.html#clustersetupprimarysettings) instead. */
436
- setupMaster(settings?: ClusterSettings): void;
437
- /**
438
- * `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in `cluster.settings`.
439
- *
440
- * Any settings changes only affect future calls to [`.fork()`](https://nodejs.org/docs/latest-v24.x/api/cluster.html#clusterforkenv)
441
- * and have no effect on workers that are already running.
442
- *
443
- * The only attribute of a worker that cannot be set via `.setupPrimary()` is the `env` passed to
444
- * [`.fork()`](https://nodejs.org/docs/latest-v24.x/api/cluster.html#clusterforkenv).
445
- *
446
- * The defaults above apply to the first call only; the defaults for later calls are the current values at the time of
447
- * `cluster.setupPrimary()` is called.
448
- *
449
- * ```js
450
- * import cluster from 'node:cluster';
451
- *
452
- * cluster.setupPrimary({
453
- * exec: 'worker.js',
454
- * args: ['--use', 'https'],
455
- * silent: true,
456
- * });
457
- * cluster.fork(); // https worker
458
- * cluster.setupPrimary({
459
- * exec: 'worker.js',
460
- * args: ['--use', 'http'],
461
- * });
462
- * cluster.fork(); // http worker
463
- * ```
464
- *
465
- * This can only be called from the primary process.
466
- * @since v16.0.0
467
- */
468
- setupPrimary(settings?: ClusterSettings): void;
469
- /**
470
- * A reference to the current worker object. Not available in the primary process.
471
- *
472
- * ```js
473
- * import cluster from 'node:cluster';
474
- *
475
- * if (cluster.isPrimary) {
476
- * console.log('I am primary');
477
- * cluster.fork();
478
- * cluster.fork();
479
- * } else if (cluster.isWorker) {
480
- * console.log(`I am worker #${cluster.worker.id}`);
481
- * }
482
- * ```
483
- * @since v0.7.0
484
- */
485
- readonly worker?: Worker | undefined;
486
- /**
487
- * 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.
488
- *
489
- * 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
490
- * is guaranteed that the removal from the `cluster.workers` list happens before the last `'disconnect'` or `'exit'` event is emitted.
491
- *
492
- * ```js
493
- * import cluster from 'node:cluster';
494
- *
495
- * for (const worker of Object.values(cluster.workers)) {
496
- * worker.send('big announcement to all workers');
497
- * }
498
- * ```
499
- * @since v0.7.0
500
- */
501
- readonly workers?: NodeJS.Dict<Worker> | undefined;
502
- readonly SCHED_NONE: number;
503
- readonly SCHED_RR: number;
504
- /**
505
- * events.EventEmitter
506
- * 1. disconnect
507
- * 2. exit
508
- * 3. fork
509
- * 4. listening
510
- * 5. message
511
- * 6. online
512
- * 7. setup
513
- */
514
- addListener(event: string, listener: (...args: any[]) => void): this;
515
- addListener(event: "disconnect", listener: (worker: Worker) => void): this;
516
- addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
517
- addListener(event: "fork", listener: (worker: Worker) => void): this;
518
- addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
519
- addListener(
520
- event: "message",
521
- listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void,
522
- ): this; // the handle is a net.Socket or net.Server object, or undefined.
523
- addListener(event: "online", listener: (worker: Worker) => void): this;
524
- addListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
525
- emit(event: string | symbol, ...args: any[]): boolean;
526
- emit(event: "disconnect", worker: Worker): boolean;
527
- emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
528
- emit(event: "fork", worker: Worker): boolean;
529
- emit(event: "listening", worker: Worker, address: Address): boolean;
530
- emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
531
- emit(event: "online", worker: Worker): boolean;
532
- emit(event: "setup", settings: ClusterSettings): boolean;
533
- on(event: string, listener: (...args: any[]) => void): this;
534
- on(event: "disconnect", listener: (worker: Worker) => void): this;
535
- on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
536
- on(event: "fork", listener: (worker: Worker) => void): this;
537
- on(event: "listening", listener: (worker: Worker, address: Address) => void): this;
538
- on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
539
- on(event: "online", listener: (worker: Worker) => void): this;
540
- on(event: "setup", listener: (settings: ClusterSettings) => void): this;
541
- once(event: string, listener: (...args: any[]) => void): this;
542
- once(event: "disconnect", listener: (worker: Worker) => void): this;
543
- once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
544
- once(event: "fork", listener: (worker: Worker) => void): this;
545
- once(event: "listening", listener: (worker: Worker, address: Address) => void): this;
546
- once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
547
- once(event: "online", listener: (worker: Worker) => void): this;
548
- once(event: "setup", listener: (settings: ClusterSettings) => void): this;
549
- prependListener(event: string, listener: (...args: any[]) => void): this;
550
- prependListener(event: "disconnect", listener: (worker: Worker) => void): this;
551
- prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
552
- prependListener(event: "fork", listener: (worker: Worker) => void): this;
553
- prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
554
- // the handle is a net.Socket or net.Server object, or undefined.
555
- prependListener(
556
- event: "message",
557
- listener: (worker: Worker, message: any, handle?: net.Socket | net.Server) => void,
558
- ): this;
559
- prependListener(event: "online", listener: (worker: Worker) => void): this;
560
- prependListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
561
- prependOnceListener(event: string, listener: (...args: any[]) => void): this;
562
- prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this;
563
- prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
564
- prependOnceListener(event: "fork", listener: (worker: Worker) => void): this;
565
- prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
566
- // the handle is a net.Socket or net.Server object, or undefined.
567
- prependOnceListener(
568
- event: "message",
569
- listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void,
570
- ): this;
571
- prependOnceListener(event: "online", listener: (worker: Worker) => void): this;
572
- prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
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
- const cluster: Cluster;
575
- export default cluster;
496
+ var cluster: cluster.Cluster;
497
+ export = cluster;
576
498
  }