@types/node 22.15.33 → 24.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. node v24.10/README.md +15 -0
  2. node v24.10/assert/strict.d.ts +111 -0
  3. {node v22.15 → node v24.10}/assert.d.ts +162 -101
  4. {node v22.15 → node v24.10}/async_hooks.d.ts +26 -6
  5. {node v22.15 → node v24.10}/buffer.buffer.d.ts +9 -0
  6. {node v22.15 → node v24.10}/buffer.d.ts +15 -7
  7. {node v22.15 → node v24.10}/child_process.d.ts +91 -164
  8. {node v22.15 → node v24.10}/cluster.d.ts +19 -20
  9. {node v22.15 → node v24.10}/compatibility/iterators.d.ts +1 -0
  10. {node v22.15 → node v24.10}/console.d.ts +19 -18
  11. {node v22.15 → node v24.10}/crypto.d.ts +1264 -356
  12. {node v22.15 → node v24.10}/dgram.d.ts +10 -9
  13. {node v22.15 → node v24.10}/diagnostics_channel.d.ts +1 -3
  14. {node v22.15 → node v24.10}/dns/promises.d.ts +12 -11
  15. {node v22.15 → node v24.10}/dns.d.ts +41 -37
  16. {node v22.15 → node v24.10}/domain.d.ts +1 -1
  17. {node v22.15 → node v24.10}/events.d.ts +81 -36
  18. {node v22.15 → node v24.10}/fs/promises.d.ts +101 -57
  19. {node v22.15 → node v24.10}/fs.d.ts +413 -136
  20. node v24.10/globals.d.ts +170 -0
  21. node v24.10/globals.typedarray.d.ts +41 -0
  22. {node v22.15 → node v24.10}/http.d.ts +187 -37
  23. {node v22.15 → node v24.10}/http2.d.ts +197 -66
  24. {node v22.15 → node v24.10}/https.d.ts +97 -63
  25. {node v22.15 → node v24.10}/index.d.ts +16 -7
  26. node v24.10/inspector.d.ts +277 -0
  27. node v22.15/inspector.d.ts → node v24.10/inspector.generated.d.ts +1059 -828
  28. {node v22.15 → node v24.10}/module.d.ts +90 -30
  29. {node v22.15 → node v24.10}/net.d.ts +35 -16
  30. {node v22.15 → node v24.10}/os.d.ts +22 -10
  31. {node v22.15 → node v24.10}/package.json +14 -84
  32. {node v22.15 → node v24.10}/path.d.ts +2 -2
  33. {node v22.15 → node v24.10}/perf_hooks.d.ts +28 -16
  34. {node v22.15 → node v24.10}/process.d.ts +40 -34
  35. {node v22.15 → node v24.10}/punycode.d.ts +1 -1
  36. {node v22.15 → node v24.10}/querystring.d.ts +1 -1
  37. {node v22.15 → node v24.10}/readline/promises.d.ts +1 -2
  38. {node v22.15 → node v24.10}/readline.d.ts +13 -13
  39. {node v22.15 → node v24.10}/repl.d.ts +25 -17
  40. {node v22.15 → node v24.10}/sea.d.ts +10 -1
  41. {node v22.15 → node v24.10}/sqlite.d.ts +438 -9
  42. {node v22.15 → node v24.10}/stream/consumers.d.ts +2 -2
  43. {node v22.15 → node v24.10}/stream/web.d.ts +13 -54
  44. {node v22.15 → node v24.10}/stream.d.ts +63 -48
  45. {node v22.15 → node v24.10}/string_decoder.d.ts +3 -3
  46. node v24.10/test.d.ts +2339 -0
  47. {node v22.15 → node v24.10}/timers/promises.d.ts +1 -1
  48. {node v22.15 → node v24.10}/timers.d.ts +1 -3
  49. {node v22.15 → node v24.10}/tls.d.ts +124 -114
  50. {node v22.15 → node v24.10}/trace_events.d.ts +6 -6
  51. {node v22.15 → node v24.10}/ts5.6/buffer.buffer.d.ts +10 -2
  52. node v24.10/ts5.6/compatibility/float16array.d.ts +71 -0
  53. node v24.10/ts5.6/globals.typedarray.d.ts +36 -0
  54. {node v22.15 → node v24.10}/ts5.6/index.d.ts +18 -7
  55. node v24.10/ts5.7/compatibility/float16array.d.ts +72 -0
  56. node v24.10/ts5.7/index.d.ts +103 -0
  57. {node v22.15 → node v24.10}/tty.d.ts +1 -1
  58. {node v22.15 → node v24.10}/url.d.ts +119 -34
  59. {node v22.15 → node v24.10}/util.d.ts +45 -304
  60. {node v22.15 → node v24.10}/v8.d.ts +68 -38
  61. {node v22.15 → node v24.10}/vm.d.ts +258 -107
  62. {node v22.15 → node v24.10}/wasi.d.ts +23 -2
  63. node v24.10/web-globals/abortcontroller.d.ts +34 -0
  64. node v24.10/web-globals/crypto.d.ts +32 -0
  65. node v24.10/web-globals/domexception.d.ts +68 -0
  66. node v22.15/dom-events.d.ts → node v24.10/web-globals/events.d.ts +49 -51
  67. node v24.10/web-globals/fetch.d.ts +50 -0
  68. node v24.10/web-globals/navigator.d.ts +25 -0
  69. node v24.10/web-globals/storage.d.ts +24 -0
  70. node v24.10/web-globals/streams.d.ts +22 -0
  71. {node v22.15 → node v24.10}/worker_threads.d.ts +206 -68
  72. {node v22.15 → node v24.10}/zlib.d.ts +44 -33
  73. node v22.15/README.md +0 -15
  74. node v22.15/assert/strict.d.ts +0 -8
  75. node v22.15/compatibility/disposable.d.ts +0 -14
  76. node v22.15/compatibility/index.d.ts +0 -9
  77. node v22.15/compatibility/indexable.d.ts +0 -20
  78. node v22.15/globals.d.ts +0 -364
  79. node v22.15/globals.typedarray.d.ts +0 -21
  80. node v22.15/test.d.ts +0 -2278
  81. node v22.15/ts5.6/globals.typedarray.d.ts +0 -19
  82. {node v22.15 → node v24.10}/LICENSE +0 -0
  83. {node v22.15 → node v24.10}/constants.d.ts +0 -0
  84. {node v22.15 → node v24.10}/stream/promises.d.ts +0 -0
@@ -15,28 +15,31 @@
15
15
  *
16
16
  * ```js
17
17
  * import {
18
- * Worker, isMainThread, parentPort, workerData,
18
+ * Worker,
19
+ * isMainThread,
20
+ * parentPort,
21
+ * workerData,
19
22
  * } from 'node:worker_threads';
20
- * import { parse } from 'some-js-parsing-library';
21
23
  *
22
- * if (isMainThread) {
23
- * module.exports = function parseJSAsync(script) {
24
- * return new Promise((resolve, reject) => {
25
- * const worker = new Worker(__filename, {
26
- * workerData: script,
27
- * });
28
- * worker.on('message', resolve);
29
- * worker.on('error', reject);
30
- * worker.on('exit', (code) => {
31
- * if (code !== 0)
32
- * reject(new Error(`Worker stopped with exit code ${code}`));
33
- * });
34
- * });
35
- * };
36
- * } else {
24
+ * if (!isMainThread) {
25
+ * const { parse } = await import('some-js-parsing-library');
37
26
  * const script = workerData;
38
27
  * parentPort.postMessage(parse(script));
39
28
  * }
29
+ *
30
+ * export default function parseJSAsync(script) {
31
+ * return new Promise((resolve, reject) => {
32
+ * const worker = new Worker(new URL(import.meta.url), {
33
+ * workerData: script,
34
+ * });
35
+ * worker.on('message', resolve);
36
+ * worker.on('error', reject);
37
+ * worker.on('exit', (code) => {
38
+ * if (code !== 0)
39
+ * reject(new Error(`Worker stopped with exit code ${code}`));
40
+ * });
41
+ * });
42
+ * };
40
43
  * ```
41
44
  *
42
45
  * The above example spawns a Worker thread for each `parseJSAsync()` call. In
@@ -49,22 +52,25 @@
49
52
  *
50
53
  * Worker threads inherit non-process-specific options by default. Refer to `Worker constructor options` to know how to customize worker thread options,
51
54
  * specifically `argv` and `execArgv` options.
52
- * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/worker_threads.js)
55
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/worker_threads.js)
53
56
  */
54
57
  declare module "worker_threads" {
55
58
  import { Context } from "node:vm";
56
- import { EventEmitter } from "node:events";
59
+ import { EventEmitter, NodeEventTarget } from "node:events";
57
60
  import { EventLoopUtilityFunction } from "node:perf_hooks";
58
61
  import { FileHandle } from "node:fs/promises";
59
62
  import { Readable, Writable } from "node:stream";
60
63
  import { ReadableStream, TransformStream, WritableStream } from "node:stream/web";
61
64
  import { URL } from "node:url";
65
+ import { CPUProfileHandle, HeapInfo, HeapProfileHandle } from "node:v8";
66
+ import { MessageEvent } from "undici-types";
62
67
  const isInternalThread: boolean;
63
68
  const isMainThread: boolean;
64
69
  const parentPort: null | MessagePort;
65
70
  const resourceLimits: ResourceLimits;
66
71
  const SHARE_ENV: unique symbol;
67
72
  const threadId: number;
73
+ const threadName: string | null;
68
74
  const workerData: any;
69
75
  /**
70
76
  * Instances of the `worker.MessageChannel` class represent an asynchronous,
@@ -97,6 +103,7 @@ declare module "worker_threads" {
97
103
  | WritableStream
98
104
  | TransformStream;
99
105
  /** @deprecated Use `import { Transferable } from "node:worker_threads"` instead. */
106
+ // TODO: remove in a future major @types/node version.
100
107
  type TransferListItem = Transferable;
101
108
  /**
102
109
  * Instances of the `worker.MessagePort` class represent one end of an
@@ -106,7 +113,7 @@ declare module "worker_threads" {
106
113
  * This implementation matches [browser `MessagePort`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort) s.
107
114
  * @since v10.5.0
108
115
  */
109
- class MessagePort extends EventEmitter {
116
+ class MessagePort implements EventTarget {
110
117
  /**
111
118
  * Disables further sending of messages on either side of the connection.
112
119
  * This method can be called when no further communication will happen over this `MessagePort`.
@@ -183,6 +190,11 @@ declare module "worker_threads" {
183
190
  * @since v10.5.0
184
191
  */
185
192
  postMessage(value: any, transferList?: readonly Transferable[]): void;
193
+ /**
194
+ * If true, the `MessagePort` object will keep the Node.js event loop active.
195
+ * @since v18.1.0, v16.17.0
196
+ */
197
+ hasRef(): boolean;
186
198
  /**
187
199
  * Opposite of `unref()`. Calling `ref()` on a previously `unref()`ed port does _not_ let the program exit if it's the only active handle left (the default
188
200
  * behavior). If the port is `ref()`ed, calling `ref()` again has no effect.
@@ -214,42 +226,32 @@ declare module "worker_threads" {
214
226
  * @since v10.5.0
215
227
  */
216
228
  start(): void;
217
- addListener(event: "close", listener: () => void): this;
229
+ addListener(event: "close", listener: (ev: Event) => void): this;
218
230
  addListener(event: "message", listener: (value: any) => void): this;
219
231
  addListener(event: "messageerror", listener: (error: Error) => void): this;
220
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
221
- emit(event: "close"): boolean;
232
+ addListener(event: string, listener: (arg: any) => void): this;
233
+ emit(event: "close", ev: Event): boolean;
222
234
  emit(event: "message", value: any): boolean;
223
235
  emit(event: "messageerror", error: Error): boolean;
224
- emit(event: string | symbol, ...args: any[]): boolean;
225
- on(event: "close", listener: () => void): this;
236
+ emit(event: string, arg: any): boolean;
237
+ off(event: "close", listener: (ev: Event) => void, options?: EventListenerOptions): this;
238
+ off(event: "message", listener: (value: any) => void, options?: EventListenerOptions): this;
239
+ off(event: "messageerror", listener: (error: Error) => void, options?: EventListenerOptions): this;
240
+ off(event: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
241
+ on(event: "close", listener: (ev: Event) => void): this;
226
242
  on(event: "message", listener: (value: any) => void): this;
227
243
  on(event: "messageerror", listener: (error: Error) => void): this;
228
- on(event: string | symbol, listener: (...args: any[]) => void): this;
229
- once(event: "close", listener: () => void): this;
244
+ on(event: string, listener: (arg: any) => void): this;
245
+ once(event: "close", listener: (ev: Event) => void): this;
230
246
  once(event: "message", listener: (value: any) => void): this;
231
247
  once(event: "messageerror", listener: (error: Error) => void): this;
232
- once(event: string | symbol, listener: (...args: any[]) => void): this;
233
- prependListener(event: "close", listener: () => void): this;
234
- prependListener(event: "message", listener: (value: any) => void): this;
235
- prependListener(event: "messageerror", listener: (error: Error) => void): this;
236
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
237
- prependOnceListener(event: "close", listener: () => void): this;
238
- prependOnceListener(event: "message", listener: (value: any) => void): this;
239
- prependOnceListener(event: "messageerror", listener: (error: Error) => void): this;
240
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
241
- removeListener(event: "close", listener: () => void): this;
242
- removeListener(event: "message", listener: (value: any) => void): this;
243
- removeListener(event: "messageerror", listener: (error: Error) => void): this;
244
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
245
- off(event: "close", listener: () => void): this;
246
- off(event: "message", listener: (value: any) => void): this;
247
- off(event: "messageerror", listener: (error: Error) => void): this;
248
- off(event: string | symbol, listener: (...args: any[]) => void): this;
249
- addEventListener: EventTarget["addEventListener"];
250
- dispatchEvent: EventTarget["dispatchEvent"];
251
- removeEventListener: EventTarget["removeEventListener"];
248
+ once(event: string, listener: (arg: any) => void): this;
249
+ removeListener(event: "close", listener: (ev: Event) => void, options?: EventListenerOptions): this;
250
+ removeListener(event: "message", listener: (value: any) => void, options?: EventListenerOptions): this;
251
+ removeListener(event: "messageerror", listener: (error: Error) => void, options?: EventListenerOptions): this;
252
+ removeListener(event: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
252
253
  }
254
+ interface MessagePort extends NodeEventTarget {}
253
255
  interface WorkerOptions {
254
256
  /**
255
257
  * List of arguments which would be stringified and appended to
@@ -391,6 +393,12 @@ declare module "worker_threads" {
391
393
  * @since v10.5.0
392
394
  */
393
395
  readonly threadId: number;
396
+ /**
397
+ * A string identifier for the referenced thread or null if the thread is not running.
398
+ * Inside the worker thread, it is available as `require('node:worker_threads').threadName`.
399
+ * @since v24.6.0
400
+ */
401
+ readonly threadName: string | null;
394
402
  /**
395
403
  * Provides the set of JS engine resource constraints for this Worker thread.
396
404
  * If the `resourceLimits` option was passed to the `Worker` constructor,
@@ -418,24 +426,6 @@ declare module "worker_threads" {
418
426
  * @since v10.5.0
419
427
  */
420
428
  postMessage(value: any, transferList?: readonly Transferable[]): void;
421
- /**
422
- * Sends a value to another worker, identified by its thread ID.
423
- * @param threadId The target thread ID. If the thread ID is invalid, a `ERR_WORKER_MESSAGING_FAILED` error will be thrown.
424
- * If the target thread ID is the current thread ID, a `ERR_WORKER_MESSAGING_SAME_THREAD` error will be thrown.
425
- * @param value The value to send.
426
- * @param transferList If one or more `MessagePort`-like objects are passed in value, a `transferList` is required for those items
427
- * or `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST` is thrown. See `port.postMessage()` for more information.
428
- * @param timeout Time to wait for the message to be delivered in milliseconds. By default it's `undefined`, which means wait forever.
429
- * If the operation times out, a `ERR_WORKER_MESSAGING_TIMEOUT` error is thrown.
430
- * @since v22.5.0
431
- */
432
- postMessageToThread(threadId: number, value: any, timeout?: number): Promise<void>;
433
- postMessageToThread(
434
- threadId: number,
435
- value: any,
436
- transferList: readonly Transferable[],
437
- timeout?: number,
438
- ): Promise<void>;
439
429
  /**
440
430
  * Opposite of `unref()`, calling `ref()` on a previously `unref()`ed worker does _not_ let the program exit if it's the only active handle left (the default
441
431
  * behavior). If the worker is `ref()`ed, calling `ref()` again has
@@ -455,6 +445,13 @@ declare module "worker_threads" {
455
445
  * @since v10.5.0
456
446
  */
457
447
  terminate(): Promise<number>;
448
+ /**
449
+ * This method returns a `Promise` that will resolve to an object identical to `process.threadCpuUsage()`,
450
+ * or reject with an `ERR_WORKER_NOT_RUNNING` error if the worker is no longer running.
451
+ * This methods allows the statistics to be observed from outside the actual thread.
452
+ * @since v24.6.0
453
+ */
454
+ cpuUsage(prev?: NodeJS.CpuUsage): Promise<NodeJS.CpuUsage>;
458
455
  /**
459
456
  * Returns a readable stream for a V8 snapshot of the current state of the Worker.
460
457
  * See `v8.getHeapSnapshot()` for more details.
@@ -465,6 +462,100 @@ declare module "worker_threads" {
465
462
  * @return A promise for a Readable Stream containing a V8 heap snapshot
466
463
  */
467
464
  getHeapSnapshot(): Promise<Readable>;
465
+ /**
466
+ * This method returns a `Promise` that will resolve to an object identical to `v8.getHeapStatistics()`,
467
+ * or reject with an `ERR_WORKER_NOT_RUNNING` error if the worker is no longer running.
468
+ * This methods allows the statistics to be observed from outside the actual thread.
469
+ * @since v24.0.0
470
+ */
471
+ getHeapStatistics(): Promise<HeapInfo>;
472
+ /**
473
+ * Starting a CPU profile then return a Promise that fulfills with an error
474
+ * or an `CPUProfileHandle` object. This API supports `await using` syntax.
475
+ *
476
+ * ```js
477
+ * const { Worker } = require('node:worker_threads');
478
+ *
479
+ * const worker = new Worker(`
480
+ * const { parentPort } = require('worker_threads');
481
+ * parentPort.on('message', () => {});
482
+ * `, { eval: true });
483
+ *
484
+ * worker.on('online', async () => {
485
+ * const handle = await worker.startCpuProfile();
486
+ * const profile = await handle.stop();
487
+ * console.log(profile);
488
+ * worker.terminate();
489
+ * });
490
+ * ```
491
+ *
492
+ * `await using` example.
493
+ *
494
+ * ```js
495
+ * const { Worker } = require('node:worker_threads');
496
+ *
497
+ * const w = new Worker(`
498
+ * const { parentPort } = require('node:worker_threads');
499
+ * parentPort.on('message', () => {});
500
+ * `, { eval: true });
501
+ *
502
+ * w.on('online', async () => {
503
+ * // Stop profile automatically when return and profile will be discarded
504
+ * await using handle = await w.startCpuProfile();
505
+ * });
506
+ * ```
507
+ * @since v24.8.0
508
+ */
509
+ startCpuProfile(): Promise<CPUProfileHandle>;
510
+ /**
511
+ * Starting a Heap profile then return a Promise that fulfills with an error
512
+ * or an `HeapProfileHandle` object. This API supports `await using` syntax.
513
+ *
514
+ * ```js
515
+ * const { Worker } = require('node:worker_threads');
516
+ *
517
+ * const worker = new Worker(`
518
+ * const { parentPort } = require('worker_threads');
519
+ * parentPort.on('message', () => {});
520
+ * `, { eval: true });
521
+ *
522
+ * worker.on('online', async () => {
523
+ * const handle = await worker.startHeapProfile();
524
+ * const profile = await handle.stop();
525
+ * console.log(profile);
526
+ * worker.terminate();
527
+ * });
528
+ * ```
529
+ *
530
+ * `await using` example.
531
+ *
532
+ * ```js
533
+ * const { Worker } = require('node:worker_threads');
534
+ *
535
+ * const w = new Worker(`
536
+ * const { parentPort } = require('node:worker_threads');
537
+ * parentPort.on('message', () => {});
538
+ * `, { eval: true });
539
+ *
540
+ * w.on('online', async () => {
541
+ * // Stop profile automatically when return and profile will be discarded
542
+ * await using handle = await w.startHeapProfile();
543
+ * });
544
+ * ```
545
+ */
546
+ startHeapProfile(): Promise<HeapProfileHandle>;
547
+ /**
548
+ * Calls `worker.terminate()` when the dispose scope is exited.
549
+ *
550
+ * ```js
551
+ * async function example() {
552
+ * await using worker = new Worker('for (;;) {}', { eval: true });
553
+ * // Worker is automatically terminate when the scope is exited.
554
+ * }
555
+ * ```
556
+ * @since v24.2.0
557
+ */
558
+ [Symbol.asyncDispose](): Promise<void>;
468
559
  addListener(event: "error", listener: (err: Error) => void): this;
469
560
  addListener(event: "exit", listener: (exitCode: number) => void): this;
470
561
  addListener(event: "message", listener: (value: any) => void): this;
@@ -545,18 +636,18 @@ declare module "worker_threads" {
545
636
  * ```
546
637
  * @since v15.4.0
547
638
  */
548
- class BroadcastChannel {
639
+ class BroadcastChannel extends EventTarget {
549
640
  readonly name: string;
550
641
  /**
551
642
  * Invoked with a single \`MessageEvent\` argument when a message is received.
552
643
  * @since v15.4.0
553
644
  */
554
- onmessage: (message: unknown) => void;
645
+ onmessage: (message: MessageEvent) => void;
555
646
  /**
556
647
  * Invoked with a received message cannot be deserialized.
557
648
  * @since v15.4.0
558
649
  */
559
- onmessageerror: (message: unknown) => void;
650
+ onmessageerror: (message: MessageEvent) => void;
560
651
  constructor(name: string);
561
652
  /**
562
653
  * Closes the `BroadcastChannel` connection.
@@ -569,6 +660,35 @@ declare module "worker_threads" {
569
660
  */
570
661
  postMessage(message: unknown): void;
571
662
  }
663
+ interface Lock {
664
+ readonly mode: LockMode;
665
+ readonly name: string;
666
+ }
667
+ interface LockGrantedCallback<T> {
668
+ (lock: Lock | null): T;
669
+ }
670
+ interface LockInfo {
671
+ clientId: string;
672
+ mode: LockMode;
673
+ name: string;
674
+ }
675
+ interface LockManager {
676
+ query(): Promise<LockManagerSnapshot>;
677
+ request<T>(name: string, callback: LockGrantedCallback<T>): Promise<Awaited<T>>;
678
+ request<T>(name: string, options: LockOptions, callback: LockGrantedCallback<T>): Promise<Awaited<T>>;
679
+ }
680
+ interface LockManagerSnapshot {
681
+ held: LockInfo[];
682
+ pending: LockInfo[];
683
+ }
684
+ type LockMode = "exclusive" | "shared";
685
+ interface LockOptions {
686
+ ifAvailable?: boolean;
687
+ mode?: LockMode;
688
+ signal?: AbortSignal;
689
+ steal?: boolean;
690
+ }
691
+ var locks: LockManager;
572
692
  /**
573
693
  * Mark an object as not transferable. If `object` occurs in the transfer list of
574
694
  * a `port.postMessage()` call, it is ignored.
@@ -710,6 +830,24 @@ declare module "worker_threads" {
710
830
  * for the `key` will be deleted.
711
831
  */
712
832
  function setEnvironmentData(key: Serializable, value?: Serializable): void;
833
+ /**
834
+ * Sends a value to another worker, identified by its thread ID.
835
+ * @param threadId The target thread ID. If the thread ID is invalid, a `ERR_WORKER_MESSAGING_FAILED` error will be thrown.
836
+ * If the target thread ID is the current thread ID, a `ERR_WORKER_MESSAGING_SAME_THREAD` error will be thrown.
837
+ * @param value The value to send.
838
+ * @param transferList If one or more `MessagePort`-like objects are passed in value, a `transferList` is required for those items
839
+ * or `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST` is thrown. See `port.postMessage()` for more information.
840
+ * @param timeout Time to wait for the message to be delivered in milliseconds. By default it's `undefined`, which means wait forever.
841
+ * If the operation times out, a `ERR_WORKER_MESSAGING_TIMEOUT` error is thrown.
842
+ * @since v22.5.0
843
+ */
844
+ function postMessageToThread(threadId: number, value: any, timeout?: number): Promise<void>;
845
+ function postMessageToThread(
846
+ threadId: number,
847
+ value: any,
848
+ transferList: readonly Transferable[],
849
+ timeout?: number,
850
+ ): Promise<void>;
713
851
 
714
852
  import {
715
853
  BroadcastChannel as _BroadcastChannel,
@@ -9,7 +9,7 @@
9
9
  * ```
10
10
  *
11
11
  * Compression and decompression are built around the Node.js
12
- * [Streams API](https://nodejs.org/docs/latest-v22.x/api/stream.html).
12
+ * [Streams API](https://nodejs.org/docs/latest-v24.x/api/stream.html).
13
13
  *
14
14
  * Compressing or decompressing a stream (such as a file) can be accomplished by
15
15
  * piping the source stream through a `zlib` `Transform` stream into a destination
@@ -89,9 +89,10 @@
89
89
  * });
90
90
  * ```
91
91
  * @since v0.5.8
92
- * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/zlib.js)
92
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/zlib.js)
93
93
  */
94
94
  declare module "zlib" {
95
+ import { NonSharedBuffer } from "node:buffer";
95
96
  import * as stream from "node:stream";
96
97
  interface ZlibOptions {
97
98
  /**
@@ -143,10 +144,14 @@ declare module "zlib" {
143
144
  }
144
145
  | undefined;
145
146
  /**
146
- * Limits output size when using [convenience methods](https://nodejs.org/docs/latest-v22.x/api/zlib.html#convenience-methods).
147
+ * Limits output size when using [convenience methods](https://nodejs.org/docs/latest-v24.x/api/zlib.html#convenience-methods).
147
148
  * @default buffer.kMaxLength
148
149
  */
149
150
  maxOutputLength?: number | undefined;
151
+ /**
152
+ * If `true`, returns an object with `buffer` and `engine`.
153
+ */
154
+ info?: boolean | undefined;
150
155
  }
151
156
  interface ZstdOptions {
152
157
  /**
@@ -163,19 +168,27 @@ declare module "zlib" {
163
168
  chunkSize?: number | undefined;
164
169
  /**
165
170
  * Key-value object containing indexed
166
- * [Zstd parameters](https://nodejs.org/docs/latest-v22.x/api/zlib.html#zstd-constants).
171
+ * [Zstd parameters](https://nodejs.org/docs/latest-v24.x/api/zlib.html#zstd-constants).
167
172
  */
168
173
  params?: { [key: number]: number | boolean } | undefined;
169
174
  /**
170
175
  * Limits output size when using
171
- * [convenience methods](https://nodejs.org/docs/latest-v22.x/api/zlib.html#convenience-methods).
176
+ * [convenience methods](https://nodejs.org/docs/latest-v24.x/api/zlib.html#convenience-methods).
172
177
  * @default buffer.kMaxLength
173
178
  */
174
179
  maxOutputLength?: number | undefined;
180
+ /**
181
+ * If `true`, returns an object with `buffer` and `engine`.
182
+ */
183
+ info?: boolean | undefined;
184
+ /**
185
+ * Optional dictionary used to improve compression efficiency when compressing or decompressing data that
186
+ * shares common patterns with the dictionary.
187
+ * @since v24.6.0
188
+ */
189
+ dictionary?: NodeJS.ArrayBufferView | undefined;
175
190
  }
176
191
  interface Zlib {
177
- /** @deprecated Use bytesWritten instead. */
178
- readonly bytesRead: number;
179
192
  readonly bytesWritten: number;
180
193
  shell?: boolean | string | undefined;
181
194
  close(callback?: () => void): void;
@@ -215,7 +228,7 @@ declare module "zlib" {
215
228
  * @returns A 32-bit unsigned integer containing the checksum.
216
229
  * @since v22.2.0
217
230
  */
218
- function crc32(data: string | Buffer | NodeJS.ArrayBufferView, value?: number): number;
231
+ function crc32(data: string | NodeJS.ArrayBufferView, value?: number): number;
219
232
  /**
220
233
  * Creates and returns a new `BrotliCompress` object.
221
234
  * @since v11.7.0, v10.16.0
@@ -279,124 +292,124 @@ declare module "zlib" {
279
292
  */
280
293
  function createZstdDecompress(options?: ZstdOptions): ZstdDecompress;
281
294
  type InputType = string | ArrayBuffer | NodeJS.ArrayBufferView;
282
- type CompressCallback = (error: Error | null, result: Buffer) => void;
295
+ type CompressCallback = (error: Error | null, result: NonSharedBuffer) => void;
283
296
  /**
284
297
  * @since v11.7.0, v10.16.0
285
298
  */
286
299
  function brotliCompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void;
287
300
  function brotliCompress(buf: InputType, callback: CompressCallback): void;
288
301
  namespace brotliCompress {
289
- function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<Buffer>;
302
+ function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<NonSharedBuffer>;
290
303
  }
291
304
  /**
292
305
  * Compress a chunk of data with `BrotliCompress`.
293
306
  * @since v11.7.0, v10.16.0
294
307
  */
295
- function brotliCompressSync(buf: InputType, options?: BrotliOptions): Buffer;
308
+ function brotliCompressSync(buf: InputType, options?: BrotliOptions): NonSharedBuffer;
296
309
  /**
297
310
  * @since v11.7.0, v10.16.0
298
311
  */
299
312
  function brotliDecompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void;
300
313
  function brotliDecompress(buf: InputType, callback: CompressCallback): void;
301
314
  namespace brotliDecompress {
302
- function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<Buffer>;
315
+ function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<NonSharedBuffer>;
303
316
  }
304
317
  /**
305
318
  * Decompress a chunk of data with `BrotliDecompress`.
306
319
  * @since v11.7.0, v10.16.0
307
320
  */
308
- function brotliDecompressSync(buf: InputType, options?: BrotliOptions): Buffer;
321
+ function brotliDecompressSync(buf: InputType, options?: BrotliOptions): NonSharedBuffer;
309
322
  /**
310
323
  * @since v0.6.0
311
324
  */
312
325
  function deflate(buf: InputType, callback: CompressCallback): void;
313
326
  function deflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
314
327
  namespace deflate {
315
- function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
328
+ function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
316
329
  }
317
330
  /**
318
331
  * Compress a chunk of data with `Deflate`.
319
332
  * @since v0.11.12
320
333
  */
321
- function deflateSync(buf: InputType, options?: ZlibOptions): Buffer;
334
+ function deflateSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
322
335
  /**
323
336
  * @since v0.6.0
324
337
  */
325
338
  function deflateRaw(buf: InputType, callback: CompressCallback): void;
326
339
  function deflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
327
340
  namespace deflateRaw {
328
- function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
341
+ function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
329
342
  }
330
343
  /**
331
344
  * Compress a chunk of data with `DeflateRaw`.
332
345
  * @since v0.11.12
333
346
  */
334
- function deflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
347
+ function deflateRawSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
335
348
  /**
336
349
  * @since v0.6.0
337
350
  */
338
351
  function gzip(buf: InputType, callback: CompressCallback): void;
339
352
  function gzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
340
353
  namespace gzip {
341
- function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
354
+ function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
342
355
  }
343
356
  /**
344
357
  * Compress a chunk of data with `Gzip`.
345
358
  * @since v0.11.12
346
359
  */
347
- function gzipSync(buf: InputType, options?: ZlibOptions): Buffer;
360
+ function gzipSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
348
361
  /**
349
362
  * @since v0.6.0
350
363
  */
351
364
  function gunzip(buf: InputType, callback: CompressCallback): void;
352
365
  function gunzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
353
366
  namespace gunzip {
354
- function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
367
+ function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
355
368
  }
356
369
  /**
357
370
  * Decompress a chunk of data with `Gunzip`.
358
371
  * @since v0.11.12
359
372
  */
360
- function gunzipSync(buf: InputType, options?: ZlibOptions): Buffer;
373
+ function gunzipSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
361
374
  /**
362
375
  * @since v0.6.0
363
376
  */
364
377
  function inflate(buf: InputType, callback: CompressCallback): void;
365
378
  function inflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
366
379
  namespace inflate {
367
- function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
380
+ function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
368
381
  }
369
382
  /**
370
383
  * Decompress a chunk of data with `Inflate`.
371
384
  * @since v0.11.12
372
385
  */
373
- function inflateSync(buf: InputType, options?: ZlibOptions): Buffer;
386
+ function inflateSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
374
387
  /**
375
388
  * @since v0.6.0
376
389
  */
377
390
  function inflateRaw(buf: InputType, callback: CompressCallback): void;
378
391
  function inflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
379
392
  namespace inflateRaw {
380
- function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
393
+ function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
381
394
  }
382
395
  /**
383
396
  * Decompress a chunk of data with `InflateRaw`.
384
397
  * @since v0.11.12
385
398
  */
386
- function inflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
399
+ function inflateRawSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
387
400
  /**
388
401
  * @since v0.6.0
389
402
  */
390
403
  function unzip(buf: InputType, callback: CompressCallback): void;
391
404
  function unzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
392
405
  namespace unzip {
393
- function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<Buffer>;
406
+ function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
394
407
  }
395
408
  /**
396
409
  * Decompress a chunk of data with `Unzip`.
397
410
  * @since v0.11.12
398
411
  */
399
- function unzipSync(buf: InputType, options?: ZlibOptions): Buffer;
412
+ function unzipSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
400
413
  /**
401
414
  * @since v22.15.0
402
415
  * @experimental
@@ -404,14 +417,14 @@ declare module "zlib" {
404
417
  function zstdCompress(buf: InputType, callback: CompressCallback): void;
405
418
  function zstdCompress(buf: InputType, options: ZstdOptions, callback: CompressCallback): void;
406
419
  namespace zstdCompress {
407
- function __promisify__(buffer: InputType, options?: ZstdOptions): Promise<Buffer>;
420
+ function __promisify__(buffer: InputType, options?: ZstdOptions): Promise<NonSharedBuffer>;
408
421
  }
409
422
  /**
410
423
  * Compress a chunk of data with `ZstdCompress`.
411
424
  * @since v22.15.0
412
425
  * @experimental
413
426
  */
414
- function zstdCompressSync(buf: InputType, options?: ZstdOptions): Buffer;
427
+ function zstdCompressSync(buf: InputType, options?: ZstdOptions): NonSharedBuffer;
415
428
  /**
416
429
  * @since v22.15.0
417
430
  * @experimental
@@ -419,14 +432,14 @@ declare module "zlib" {
419
432
  function zstdDecompress(buf: InputType, callback: CompressCallback): void;
420
433
  function zstdDecompress(buf: InputType, options: ZstdOptions, callback: CompressCallback): void;
421
434
  namespace zstdDecompress {
422
- function __promisify__(buffer: InputType, options?: ZstdOptions): Promise<Buffer>;
435
+ function __promisify__(buffer: InputType, options?: ZstdOptions): Promise<NonSharedBuffer>;
423
436
  }
424
437
  /**
425
438
  * Decompress a chunk of data with `ZstdDecompress`.
426
439
  * @since v22.15.0
427
440
  * @experimental
428
441
  */
429
- function zstdDecompressSync(buf: InputType, options?: ZstdOptions): Buffer;
442
+ function zstdDecompressSync(buf: InputType, options?: ZstdOptions): NonSharedBuffer;
430
443
  namespace constants {
431
444
  const BROTLI_DECODE: number;
432
445
  const BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: number;
@@ -612,8 +625,6 @@ declare module "zlib" {
612
625
  const Z_FINISH: number;
613
626
  /** @deprecated Use `constants.Z_BLOCK` */
614
627
  const Z_BLOCK: number;
615
- /** @deprecated Use `constants.Z_TREES` */
616
- const Z_TREES: number;
617
628
  // Return codes for the compression/decompression functions.
618
629
  // Negative values are errors, positive values are used for special but normal events.
619
630
  /** @deprecated Use `constants.Z_OK` */