@types/node 20.19.25 → 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 (79) hide show
  1. {node v20.19 → node v24.10}/README.md +3 -3
  2. node v24.10/assert/strict.d.ts +111 -0
  3. {node v20.19 → node v24.10}/assert.d.ts +150 -97
  4. {node v20.19 → node v24.10}/async_hooks.d.ts +27 -9
  5. {node v20.19 → node v24.10}/buffer.buffer.d.ts +2 -1
  6. {node v20.19 → node v24.10}/buffer.d.ts +6 -8
  7. {node v20.19 → node v24.10}/child_process.d.ts +11 -10
  8. {node v20.19 → node v24.10}/cluster.d.ts +16 -15
  9. {node v20.19 → node v24.10}/console.d.ts +19 -18
  10. {node v20.19 → node v24.10}/crypto.d.ts +1120 -293
  11. {node v20.19 → node v24.10}/dgram.d.ts +5 -2
  12. {node v20.19 → node v24.10}/diagnostics_channel.d.ts +1 -3
  13. {node v20.19 → node v24.10}/dns/promises.d.ts +30 -6
  14. {node v20.19 → node v24.10}/dns.d.ts +69 -17
  15. {node v20.19 → node v24.10}/domain.d.ts +1 -1
  16. {node v20.19 → node v24.10}/events.d.ts +1 -2
  17. {node v20.19 → node v24.10}/fs/promises.d.ts +85 -38
  18. {node v20.19 → node v24.10}/fs.d.ts +387 -48
  19. {node v20.19 → node v24.10}/globals.d.ts +2 -4
  20. {node v20.19 → node v24.10}/globals.typedarray.d.ts +3 -0
  21. {node v20.19 → node v24.10}/http.d.ts +90 -5
  22. {node v20.19 → node v24.10}/http2.d.ts +166 -41
  23. {node v20.19 → node v24.10}/https.d.ts +4 -3
  24. {node v20.19 → node v24.10}/index.d.ts +13 -5
  25. node v24.10/inspector.d.ts +277 -0
  26. {node v20.19 → node v24.10}/inspector.generated.d.ts +1096 -829
  27. {node v20.19 → node v24.10}/module.d.ts +403 -48
  28. {node v20.19 → node v24.10}/net.d.ts +62 -20
  29. {node v20.19 → node v24.10}/os.d.ts +8 -7
  30. {node v20.19 → node v24.10}/package.json +18 -3
  31. {node v20.19 → node v24.10}/path.d.ts +3 -3
  32. {node v20.19 → node v24.10}/perf_hooks.d.ts +37 -16
  33. {node v20.19 → node v24.10}/process.d.ts +133 -16
  34. {node v20.19 → node v24.10}/punycode.d.ts +1 -1
  35. {node v20.19 → node v24.10}/querystring.d.ts +1 -1
  36. {node v20.19 → node v24.10}/readline/promises.d.ts +0 -1
  37. {node v20.19 → node v24.10}/readline.d.ts +19 -14
  38. {node v20.19 → node v24.10}/repl.d.ts +25 -17
  39. {node v20.19 → node v24.10}/sea.d.ts +11 -2
  40. node v24.10/sqlite.d.ts +937 -0
  41. {node v20.19 → node v24.10}/stream/web.d.ts +85 -45
  42. {node v20.19 → node v24.10}/stream.d.ts +36 -28
  43. {node v20.19 → node v24.10}/string_decoder.d.ts +1 -1
  44. {node v20.19 → node v24.10}/test.d.ts +587 -35
  45. {node v20.19 → node v24.10}/timers/promises.d.ts +1 -1
  46. {node v20.19 → node v24.10}/timers.d.ts +4 -5
  47. {node v20.19 → node v24.10}/tls.d.ts +62 -48
  48. {node v20.19 → node v24.10}/trace_events.d.ts +6 -6
  49. node v24.10/ts5.6/compatibility/float16array.d.ts +71 -0
  50. {node v20.19 → node v24.10}/ts5.6/globals.typedarray.d.ts +2 -0
  51. {node v20.19 → node v24.10}/ts5.6/index.d.ts +15 -5
  52. node v24.10/ts5.7/compatibility/float16array.d.ts +72 -0
  53. node v24.10/ts5.7/index.d.ts +103 -0
  54. {node v20.19 → node v24.10}/tty.d.ts +1 -1
  55. {node v20.19 → node v24.10}/url.d.ts +128 -35
  56. {node v20.19 → node v24.10}/util.d.ts +384 -390
  57. {node v20.19 → node v24.10}/v8.d.ts +175 -32
  58. {node v20.19 → node v24.10}/vm.d.ts +246 -67
  59. {node v20.19 → node v24.10}/wasi.d.ts +23 -2
  60. node v24.10/web-globals/crypto.d.ts +32 -0
  61. {node v20.19 → node v24.10}/web-globals/fetch.d.ts +4 -0
  62. node v24.10/web-globals/navigator.d.ts +25 -0
  63. node v24.10/web-globals/storage.d.ts +24 -0
  64. node v24.10/web-globals/streams.d.ts +22 -0
  65. {node v20.19 → node v24.10}/worker_threads.d.ts +205 -24
  66. {node v20.19 → node v24.10}/zlib.d.ts +185 -44
  67. node v20.19/assert/strict.d.ts +0 -8
  68. node v20.19/compatibility/disposable.d.ts +0 -16
  69. node v20.19/compatibility/index.d.ts +0 -9
  70. node v20.19/compatibility/indexable.d.ts +0 -20
  71. {node v20.19 → node v24.10}/LICENSE +0 -0
  72. {node v20.19 → node v24.10}/compatibility/iterators.d.ts +0 -0
  73. {node v20.19 → node v24.10}/constants.d.ts +0 -0
  74. {node v20.19 → node v24.10}/stream/consumers.d.ts +0 -0
  75. {node v20.19 → node v24.10}/stream/promises.d.ts +0 -0
  76. {node v20.19 → node v24.10}/ts5.6/buffer.buffer.d.ts +0 -0
  77. {node v20.19 → node v24.10}/web-globals/abortcontroller.d.ts +0 -0
  78. {node v20.19 → node v24.10}/web-globals/domexception.d.ts +0 -0
  79. {node v20.19 → node v24.10}/web-globals/events.d.ts +0 -0
@@ -0,0 +1,22 @@
1
+ export {};
2
+
3
+ import * as webstreams from "stream/web";
4
+
5
+ type _CompressionStream = typeof globalThis extends { onmessage: any } ? {} : webstreams.CompressionStream;
6
+ type _DecompressionStream = typeof globalThis extends { onmessage: any } ? {} : webstreams.DecompressionStream;
7
+
8
+ declare global {
9
+ interface CompressionStream extends _CompressionStream {}
10
+ var CompressionStream: typeof globalThis extends {
11
+ onmessage: any;
12
+ CompressionStream: infer T;
13
+ } ? T
14
+ : typeof webstreams.CompressionStream;
15
+
16
+ interface DecompressionStream extends _DecompressionStream {}
17
+ var DecompressionStream: typeof globalThis extends {
18
+ onmessage: any;
19
+ DecompressionStream: infer T;
20
+ } ? T
21
+ : typeof webstreams.DecompressionStream;
22
+ }
@@ -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,7 +52,7 @@
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/v20.13.1/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";
@@ -59,12 +62,15 @@ declare module "worker_threads" {
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";
62
66
  import { MessageEvent } from "undici-types";
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
@@ -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.
@@ -266,7 +278,7 @@ declare module "worker_threads" {
266
278
  trackUnmanagedFds?: boolean | undefined;
267
279
  /**
268
280
  * An optional `name` to be appended to the worker title
269
- * for debuggin/identification purposes, making the final title as
281
+ * for debugging/identification purposes, making the final title as
270
282
  * `[worker ${id}] ${name}`.
271
283
  */
272
284
  name?: string | undefined;
@@ -297,7 +309,7 @@ declare module "worker_threads" {
297
309
  * Notable differences inside a Worker environment are:
298
310
  *
299
311
  * * The `process.stdin`, `process.stdout`, and `process.stderr` streams may be redirected by the parent thread.
300
- * * The `import { isMainThread } from 'node:worker_threads'` property is set to `false`.
312
+ * * The `import { isMainThread } from 'node:worker_threads'` variable is set to `false`.
301
313
  * * The `import { parentPort } from 'node:worker_threads'` message port is available.
302
314
  * * `process.exit()` does not stop the whole program, just the single thread,
303
315
  * and `process.abort()` is not available.
@@ -376,11 +388,17 @@ declare module "worker_threads" {
376
388
  readonly stderr: Readable;
377
389
  /**
378
390
  * An integer identifier for the referenced thread. Inside the worker thread,
379
- * it is available as `import { threadId } from 'node:node:worker_threads'`.
391
+ * it is available as `import { threadId } from 'node:worker_threads'`.
380
392
  * This value is unique for each `Worker` instance inside a single process.
381
393
  * @since v10.5.0
382
394
  */
383
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;
384
402
  /**
385
403
  * Provides the set of JS engine resource constraints for this Worker thread.
386
404
  * If the `resourceLimits` option was passed to the `Worker` constructor,
@@ -427,6 +445,13 @@ declare module "worker_threads" {
427
445
  * @since v10.5.0
428
446
  */
429
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>;
430
455
  /**
431
456
  * Returns a readable stream for a V8 snapshot of the current state of the Worker.
432
457
  * See `v8.getHeapSnapshot()` for more details.
@@ -437,6 +462,100 @@ declare module "worker_threads" {
437
462
  * @return A promise for a Readable Stream containing a V8 heap snapshot
438
463
  */
439
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>;
440
559
  addListener(event: "error", listener: (err: Error) => void): this;
441
560
  addListener(event: "exit", listener: (exitCode: number) => void): this;
442
561
  addListener(event: "message", listener: (value: any) => void): this;
@@ -541,6 +660,35 @@ declare module "worker_threads" {
541
660
  */
542
661
  postMessage(message: unknown): void;
543
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;
544
692
  /**
545
693
  * Mark an object as not transferable. If `object` occurs in the transfer list of
546
694
  * a `port.postMessage()` call, it is ignored.
@@ -575,6 +723,39 @@ declare module "worker_threads" {
575
723
  * @since v14.5.0, v12.19.0
576
724
  */
577
725
  function markAsUntransferable(object: object): void;
726
+ /**
727
+ * Check if an object is marked as not transferable with
728
+ * {@link markAsUntransferable}.
729
+ * @since v21.0.0
730
+ */
731
+ function isMarkedAsUntransferable(object: object): boolean;
732
+ /**
733
+ * Mark an object as not cloneable. If `object` is used as `message` in
734
+ * a `port.postMessage()` call, an error is thrown. This is a no-op if `object` is a
735
+ * primitive value.
736
+ *
737
+ * This has no effect on `ArrayBuffer`, or any `Buffer` like objects.
738
+ *
739
+ * This operation cannot be undone.
740
+ *
741
+ * ```js
742
+ * const { markAsUncloneable } = require('node:worker_threads');
743
+ *
744
+ * const anyObject = { foo: 'bar' };
745
+ * markAsUncloneable(anyObject);
746
+ * const { port1 } = new MessageChannel();
747
+ * try {
748
+ * // This will throw an error, because anyObject is not cloneable.
749
+ * port1.postMessage(anyObject)
750
+ * } catch (error) {
751
+ * // error.name === 'DataCloneError'
752
+ * }
753
+ * ```
754
+ *
755
+ * There is no equivalent to this API in browsers.
756
+ * @since v22.10.0
757
+ */
758
+ function markAsUncloneable(object: object): void;
578
759
  /**
579
760
  * Transfer a `MessagePort` to a different `vm` Context. The original `port` object is rendered unusable, and the returned `MessagePort` instance
580
761
  * takes its place.
@@ -679,7 +860,7 @@ declare module "worker_threads" {
679
860
  options?: { transfer?: Transferable[] },
680
861
  ): T;
681
862
  /**
682
- * `BroadcastChannel` class is a global reference for `import { BroadcastChannel } from 'node:worker_threads'`
863
+ * `BroadcastChannel` class is a global reference for `import { BroadcastChannel } from 'worker_threads'`
683
864
  * https://nodejs.org/api/globals.html#broadcastchannel
684
865
  * @since v18.0.0
685
866
  */
@@ -689,7 +870,7 @@ declare module "worker_threads" {
689
870
  } ? T
690
871
  : typeof _BroadcastChannel;
691
872
  /**
692
- * `MessageChannel` class is a global reference for `import { MessageChannel } from 'node:worker_threads'`
873
+ * `MessageChannel` class is a global reference for `import { MessageChannel } from 'worker_threads'`
693
874
  * https://nodejs.org/api/globals.html#messagechannel
694
875
  * @since v15.0.0
695
876
  */
@@ -699,7 +880,7 @@ declare module "worker_threads" {
699
880
  } ? T
700
881
  : typeof _MessageChannel;
701
882
  /**
702
- * `MessagePort` class is a global reference for `import { MessagePort } from 'node:worker_threads'`
883
+ * `MessagePort` class is a global reference for `import { MessagePort } from 'worker_threads'`
703
884
  * https://nodejs.org/api/globals.html#messageport
704
885
  * @since v15.0.0
705
886
  */
@@ -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-v20.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,7 +89,7 @@
89
89
  * });
90
90
  * ```
91
91
  * @since v0.5.8
92
- * @see [source](https://github.com/nodejs/node/blob/v20.13.1/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
95
  import { NonSharedBuffer } from "node:buffer";
@@ -144,14 +144,51 @@ declare module "zlib" {
144
144
  }
145
145
  | undefined;
146
146
  /**
147
- * Limits output size when using [convenience methods](https://nodejs.org/docs/latest-v20.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).
148
148
  * @default buffer.kMaxLength
149
149
  */
150
150
  maxOutputLength?: number | undefined;
151
+ /**
152
+ * If `true`, returns an object with `buffer` and `engine`.
153
+ */
154
+ info?: boolean | undefined;
155
+ }
156
+ interface ZstdOptions {
157
+ /**
158
+ * @default constants.ZSTD_e_continue
159
+ */
160
+ flush?: number | undefined;
161
+ /**
162
+ * @default constants.ZSTD_e_end
163
+ */
164
+ finishFlush?: number | undefined;
165
+ /**
166
+ * @default 16 * 1024
167
+ */
168
+ chunkSize?: number | undefined;
169
+ /**
170
+ * Key-value object containing indexed
171
+ * [Zstd parameters](https://nodejs.org/docs/latest-v24.x/api/zlib.html#zstd-constants).
172
+ */
173
+ params?: { [key: number]: number | boolean } | undefined;
174
+ /**
175
+ * Limits output size when using
176
+ * [convenience methods](https://nodejs.org/docs/latest-v24.x/api/zlib.html#convenience-methods).
177
+ * @default buffer.kMaxLength
178
+ */
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;
151
190
  }
152
191
  interface Zlib {
153
- /** @deprecated Use bytesWritten instead. */
154
- readonly bytesRead: number;
155
192
  readonly bytesWritten: number;
156
193
  shell?: boolean | string | undefined;
157
194
  close(callback?: () => void): void;
@@ -173,13 +210,23 @@ declare module "zlib" {
173
210
  interface DeflateRaw extends stream.Transform, Zlib, ZlibReset, ZlibParams {}
174
211
  interface InflateRaw extends stream.Transform, Zlib, ZlibReset {}
175
212
  interface Unzip extends stream.Transform, Zlib {}
213
+ /**
214
+ * @since v22.15.0
215
+ * @experimental
216
+ */
217
+ interface ZstdCompress extends stream.Transform, Zlib {}
218
+ /**
219
+ * @since v22.15.0
220
+ * @experimental
221
+ */
222
+ interface ZstdDecompress extends stream.Transform, Zlib {}
176
223
  /**
177
224
  * Computes a 32-bit [Cyclic Redundancy Check](https://en.wikipedia.org/wiki/Cyclic_redundancy_check) checksum of `data`.
178
225
  * If `value` is specified, it is used as the starting value of the checksum, otherwise, 0 is used as the starting value.
179
226
  * @param data When `data` is a string, it will be encoded as UTF-8 before being used for computation.
180
227
  * @param value An optional starting value. It must be a 32-bit unsigned integer. @default 0
181
228
  * @returns A 32-bit unsigned integer containing the checksum.
182
- * @since v20.15.0
229
+ * @since v22.2.0
183
230
  */
184
231
  function crc32(data: string | NodeJS.ArrayBufferView, value?: number): number;
185
232
  /**
@@ -234,6 +281,16 @@ declare module "zlib" {
234
281
  * @since v0.5.8
235
282
  */
236
283
  function createUnzip(options?: ZlibOptions): Unzip;
284
+ /**
285
+ * Creates and returns a new `ZstdCompress` object.
286
+ * @since v22.15.0
287
+ */
288
+ function createZstdCompress(options?: ZstdOptions): ZstdCompress;
289
+ /**
290
+ * Creates and returns a new `ZstdDecompress` object.
291
+ * @since v22.15.0
292
+ */
293
+ function createZstdDecompress(options?: ZstdOptions): ZstdDecompress;
237
294
  type InputType = string | ArrayBuffer | NodeJS.ArrayBufferView;
238
295
  type CompressCallback = (error: Error | null, result: NonSharedBuffer) => void;
239
296
  /**
@@ -353,6 +410,36 @@ declare module "zlib" {
353
410
  * @since v0.11.12
354
411
  */
355
412
  function unzipSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
413
+ /**
414
+ * @since v22.15.0
415
+ * @experimental
416
+ */
417
+ function zstdCompress(buf: InputType, callback: CompressCallback): void;
418
+ function zstdCompress(buf: InputType, options: ZstdOptions, callback: CompressCallback): void;
419
+ namespace zstdCompress {
420
+ function __promisify__(buffer: InputType, options?: ZstdOptions): Promise<NonSharedBuffer>;
421
+ }
422
+ /**
423
+ * Compress a chunk of data with `ZstdCompress`.
424
+ * @since v22.15.0
425
+ * @experimental
426
+ */
427
+ function zstdCompressSync(buf: InputType, options?: ZstdOptions): NonSharedBuffer;
428
+ /**
429
+ * @since v22.15.0
430
+ * @experimental
431
+ */
432
+ function zstdDecompress(buf: InputType, callback: CompressCallback): void;
433
+ function zstdDecompress(buf: InputType, options: ZstdOptions, callback: CompressCallback): void;
434
+ namespace zstdDecompress {
435
+ function __promisify__(buffer: InputType, options?: ZstdOptions): Promise<NonSharedBuffer>;
436
+ }
437
+ /**
438
+ * Decompress a chunk of data with `ZstdDecompress`.
439
+ * @since v22.15.0
440
+ * @experimental
441
+ */
442
+ function zstdDecompressSync(buf: InputType, options?: ZstdOptions): NonSharedBuffer;
356
443
  namespace constants {
357
444
  const BROTLI_DECODE: number;
358
445
  const BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: number;
@@ -424,50 +511,106 @@ declare module "zlib" {
424
511
  const INFLATE: number;
425
512
  const INFLATERAW: number;
426
513
  const UNZIP: number;
427
- // Allowed flush values.
428
- const Z_NO_FLUSH: number;
429
- const Z_PARTIAL_FLUSH: number;
430
- const Z_SYNC_FLUSH: number;
431
- const Z_FULL_FLUSH: number;
432
- const Z_FINISH: number;
514
+ const ZLIB_VERNUM: number;
515
+ const ZSTD_CLEVEL_DEFAULT: number;
516
+ const ZSTD_COMPRESS: number;
517
+ const ZSTD_DECOMPRESS: number;
518
+ const ZSTD_btlazy2: number;
519
+ const ZSTD_btopt: number;
520
+ const ZSTD_btultra: number;
521
+ const ZSTD_btultra2: number;
522
+ const ZSTD_c_chainLog: number;
523
+ const ZSTD_c_checksumFlag: number;
524
+ const ZSTD_c_compressionLevel: number;
525
+ const ZSTD_c_contentSizeFlag: number;
526
+ const ZSTD_c_dictIDFlag: number;
527
+ const ZSTD_c_enableLongDistanceMatching: number;
528
+ const ZSTD_c_hashLog: number;
529
+ const ZSTD_c_jobSize: number;
530
+ const ZSTD_c_ldmBucketSizeLog: number;
531
+ const ZSTD_c_ldmHashLog: number;
532
+ const ZSTD_c_ldmHashRateLog: number;
533
+ const ZSTD_c_ldmMinMatch: number;
534
+ const ZSTD_c_minMatch: number;
535
+ const ZSTD_c_nbWorkers: number;
536
+ const ZSTD_c_overlapLog: number;
537
+ const ZSTD_c_searchLog: number;
538
+ const ZSTD_c_strategy: number;
539
+ const ZSTD_c_targetLength: number;
540
+ const ZSTD_c_windowLog: number;
541
+ const ZSTD_d_windowLogMax: number;
542
+ const ZSTD_dfast: number;
543
+ const ZSTD_e_continue: number;
544
+ const ZSTD_e_end: number;
545
+ const ZSTD_e_flush: number;
546
+ const ZSTD_error_GENERIC: number;
547
+ const ZSTD_error_checksum_wrong: number;
548
+ const ZSTD_error_corruption_detected: number;
549
+ const ZSTD_error_dictionaryCreation_failed: number;
550
+ const ZSTD_error_dictionary_corrupted: number;
551
+ const ZSTD_error_dictionary_wrong: number;
552
+ const ZSTD_error_dstBuffer_null: number;
553
+ const ZSTD_error_dstSize_tooSmall: number;
554
+ const ZSTD_error_frameParameter_unsupported: number;
555
+ const ZSTD_error_frameParameter_windowTooLarge: number;
556
+ const ZSTD_error_init_missing: number;
557
+ const ZSTD_error_literals_headerWrong: number;
558
+ const ZSTD_error_maxSymbolValue_tooLarge: number;
559
+ const ZSTD_error_maxSymbolValue_tooSmall: number;
560
+ const ZSTD_error_memory_allocation: number;
561
+ const ZSTD_error_noForwardProgress_destFull: number;
562
+ const ZSTD_error_noForwardProgress_inputEmpty: number;
563
+ const ZSTD_error_no_error: number;
564
+ const ZSTD_error_parameter_combination_unsupported: number;
565
+ const ZSTD_error_parameter_outOfBound: number;
566
+ const ZSTD_error_parameter_unsupported: number;
567
+ const ZSTD_error_prefix_unknown: number;
568
+ const ZSTD_error_srcSize_wrong: number;
569
+ const ZSTD_error_stabilityCondition_notRespected: number;
570
+ const ZSTD_error_stage_wrong: number;
571
+ const ZSTD_error_tableLog_tooLarge: number;
572
+ const ZSTD_error_version_unsupported: number;
573
+ const ZSTD_error_workSpace_tooSmall: number;
574
+ const ZSTD_fast: number;
575
+ const ZSTD_greedy: number;
576
+ const ZSTD_lazy: number;
577
+ const ZSTD_lazy2: number;
578
+ const Z_BEST_COMPRESSION: number;
579
+ const Z_BEST_SPEED: number;
433
580
  const Z_BLOCK: number;
434
- const Z_TREES: number;
435
- // Return codes for the compression/decompression functions.
436
- // Negative values are errors, positive values are used for special but normal events.
437
- const Z_OK: number;
438
- const Z_STREAM_END: number;
439
- const Z_NEED_DICT: number;
440
- const Z_ERRNO: number;
441
- const Z_STREAM_ERROR: number;
442
- const Z_DATA_ERROR: number;
443
- const Z_MEM_ERROR: number;
444
581
  const Z_BUF_ERROR: number;
445
- const Z_VERSION_ERROR: number;
446
- // Compression levels.
447
- const Z_NO_COMPRESSION: number;
448
- const Z_BEST_SPEED: number;
449
- const Z_BEST_COMPRESSION: number;
582
+ const Z_DATA_ERROR: number;
583
+ const Z_DEFAULT_CHUNK: number;
450
584
  const Z_DEFAULT_COMPRESSION: number;
451
- // Compression strategy.
452
- const Z_FILTERED: number;
453
- const Z_HUFFMAN_ONLY: number;
454
- const Z_RLE: number;
455
- const Z_FIXED: number;
585
+ const Z_DEFAULT_LEVEL: number;
586
+ const Z_DEFAULT_MEMLEVEL: number;
456
587
  const Z_DEFAULT_STRATEGY: number;
457
588
  const Z_DEFAULT_WINDOWBITS: number;
458
-
459
- const Z_MIN_WINDOWBITS: number;
460
- const Z_MAX_WINDOWBITS: number;
461
- const Z_MIN_CHUNK: number;
589
+ const Z_ERRNO: number;
590
+ const Z_FILTERED: number;
591
+ const Z_FINISH: number;
592
+ const Z_FIXED: number;
593
+ const Z_FULL_FLUSH: number;
594
+ const Z_HUFFMAN_ONLY: number;
462
595
  const Z_MAX_CHUNK: number;
463
- const Z_DEFAULT_CHUNK: number;
464
- const Z_MIN_MEMLEVEL: number;
596
+ const Z_MAX_LEVEL: number;
465
597
  const Z_MAX_MEMLEVEL: number;
466
- const Z_DEFAULT_MEMLEVEL: number;
598
+ const Z_MAX_WINDOWBITS: number;
599
+ const Z_MEM_ERROR: number;
600
+ const Z_MIN_CHUNK: number;
467
601
  const Z_MIN_LEVEL: number;
468
- const Z_MAX_LEVEL: number;
469
- const Z_DEFAULT_LEVEL: number;
470
- const ZLIB_VERNUM: number;
602
+ const Z_MIN_MEMLEVEL: number;
603
+ const Z_MIN_WINDOWBITS: number;
604
+ const Z_NEED_DICT: number;
605
+ const Z_NO_COMPRESSION: number;
606
+ const Z_NO_FLUSH: number;
607
+ const Z_OK: number;
608
+ const Z_PARTIAL_FLUSH: number;
609
+ const Z_RLE: number;
610
+ const Z_STREAM_END: number;
611
+ const Z_STREAM_ERROR: number;
612
+ const Z_SYNC_FLUSH: number;
613
+ const Z_VERSION_ERROR: number;
471
614
  }
472
615
  // Allowed flush values.
473
616
  /** @deprecated Use `constants.Z_NO_FLUSH` */
@@ -482,8 +625,6 @@ declare module "zlib" {
482
625
  const Z_FINISH: number;
483
626
  /** @deprecated Use `constants.Z_BLOCK` */
484
627
  const Z_BLOCK: number;
485
- /** @deprecated Use `constants.Z_TREES` */
486
- const Z_TREES: number;
487
628
  // Return codes for the compression/decompression functions.
488
629
  // Negative values are errors, positive values are used for special but normal events.
489
630
  /** @deprecated Use `constants.Z_OK` */
@@ -1,8 +0,0 @@
1
- declare module "assert/strict" {
2
- import { strict } from "node:assert";
3
- export = strict;
4
- }
5
- declare module "node:assert/strict" {
6
- import { strict } from "node:assert";
7
- export = strict;
8
- }