@types/node 18.11.5 → 20.2.5

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 (97) hide show
  1. node/README.md +2 -2
  2. node/assert.d.ts +86 -75
  3. node/async_hooks.d.ts +66 -37
  4. node/buffer.d.ts +193 -100
  5. node/child_process.d.ts +82 -56
  6. node/cluster.d.ts +12 -12
  7. node/console.d.ts +5 -5
  8. node/crypto.d.ts +233 -235
  9. node/dgram.d.ts +15 -15
  10. node/diagnostics_channel.d.ts +59 -21
  11. node/dns/promises.d.ts +50 -6
  12. node/dns.d.ts +26 -17
  13. node/domain.d.ts +4 -4
  14. node/events.d.ts +111 -65
  15. node/fs/promises.d.ts +99 -47
  16. node/fs.d.ts +244 -73
  17. node/globals.d.ts +6 -3
  18. node/http.d.ts +265 -148
  19. node/http2.d.ts +42 -47
  20. node/https.d.ts +53 -153
  21. node/index.d.ts +2 -1
  22. node/inspector.d.ts +10 -3
  23. node/module.d.ts +6 -4
  24. node/net.d.ts +32 -15
  25. node/os.d.ts +27 -16
  26. node/package.json +9 -4
  27. node/path.d.ts +4 -4
  28. node/perf_hooks.d.ts +28 -15
  29. node/process.d.ts +49 -46
  30. node/punycode.d.ts +1 -1
  31. node/querystring.d.ts +5 -5
  32. node/readline/promises.d.ts +65 -63
  33. node/readline.d.ts +32 -159
  34. node/repl.d.ts +20 -20
  35. node/stream/consumers.d.ts +1 -1
  36. node/stream.d.ts +950 -869
  37. node/string_decoder.d.ts +6 -6
  38. node/test.d.ts +877 -139
  39. node/timers/promises.d.ts +26 -1
  40. node/timers.d.ts +125 -4
  41. node/tls.d.ts +120 -29
  42. node/trace_events.d.ts +20 -9
  43. node/ts4.8/assert.d.ts +86 -75
  44. node/ts4.8/async_hooks.d.ts +66 -37
  45. node/ts4.8/buffer.d.ts +193 -101
  46. node/ts4.8/child_process.d.ts +82 -56
  47. node/ts4.8/cluster.d.ts +12 -12
  48. node/ts4.8/console.d.ts +5 -5
  49. node/ts4.8/crypto.d.ts +230 -233
  50. node/ts4.8/dgram.d.ts +15 -15
  51. node/ts4.8/diagnostics_channel.d.ts +59 -21
  52. node/ts4.8/dns/promises.d.ts +50 -6
  53. node/ts4.8/dns.d.ts +26 -17
  54. node/ts4.8/domain.d.ts +4 -4
  55. node/ts4.8/events.d.ts +111 -65
  56. node/ts4.8/fs/promises.d.ts +97 -46
  57. node/ts4.8/fs.d.ts +244 -73
  58. node/ts4.8/globals.d.ts +21 -12
  59. node/ts4.8/http.d.ts +265 -148
  60. node/ts4.8/http2.d.ts +42 -47
  61. node/ts4.8/https.d.ts +53 -153
  62. node/ts4.8/inspector.d.ts +10 -3
  63. node/ts4.8/module.d.ts +6 -4
  64. node/ts4.8/net.d.ts +33 -16
  65. node/ts4.8/os.d.ts +27 -16
  66. node/ts4.8/path.d.ts +4 -4
  67. node/ts4.8/perf_hooks.d.ts +28 -15
  68. node/ts4.8/process.d.ts +49 -46
  69. node/ts4.8/punycode.d.ts +1 -1
  70. node/ts4.8/querystring.d.ts +5 -5
  71. node/ts4.8/readline/promises.d.ts +65 -63
  72. node/ts4.8/readline.d.ts +32 -159
  73. node/ts4.8/repl.d.ts +20 -20
  74. node/ts4.8/stream/consumers.d.ts +1 -1
  75. node/ts4.8/stream.d.ts +192 -140
  76. node/ts4.8/string_decoder.d.ts +6 -6
  77. node/ts4.8/test.d.ts +877 -139
  78. node/ts4.8/timers/promises.d.ts +26 -1
  79. node/ts4.8/timers.d.ts +125 -4
  80. node/ts4.8/tls.d.ts +120 -29
  81. node/ts4.8/trace_events.d.ts +20 -9
  82. node/ts4.8/tty.d.ts +4 -5
  83. node/ts4.8/url.d.ts +46 -42
  84. node/ts4.8/util.d.ts +325 -123
  85. node/ts4.8/v8.d.ts +253 -14
  86. node/ts4.8/vm.d.ts +417 -32
  87. node/ts4.8/wasi.d.ts +13 -19
  88. node/ts4.8/worker_threads.d.ts +38 -34
  89. node/ts4.8/zlib.d.ts +11 -11
  90. node/tty.d.ts +4 -5
  91. node/url.d.ts +46 -42
  92. node/util.d.ts +325 -123
  93. node/v8.d.ts +253 -14
  94. node/vm.d.ts +417 -32
  95. node/wasi.d.ts +13 -19
  96. node/worker_threads.d.ts +38 -34
  97. node/zlib.d.ts +11 -11
node/v8.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * The `v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using:
2
+ * The `node:v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using:
3
3
  *
4
4
  * ```js
5
- * const v8 = require('v8');
5
+ * const v8 = require('node:v8');
6
6
  * ```
7
- * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/v8.js)
7
+ * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/v8.js)
8
8
  */
9
9
  declare module 'v8' {
10
10
  import { Readable } from 'node:stream';
@@ -29,6 +29,9 @@ declare module 'v8' {
29
29
  does_zap_garbage: DoesZapCodeSpaceFlag;
30
30
  number_of_native_contexts: number;
31
31
  number_of_detached_contexts: number;
32
+ total_global_handles_size: number;
33
+ used_global_handles_size: number;
34
+ external_memory: number;
32
35
  }
33
36
  interface HeapCodeStatistics {
34
37
  code_and_metadata_size: number;
@@ -68,6 +71,15 @@ declare module 'v8' {
68
71
  * of contexts that were detached and not yet garbage collected. This number
69
72
  * being non-zero indicates a potential memory leak.
70
73
  *
74
+ * `total_global_handles_size` The value of total\_global\_handles\_size is the
75
+ * total memory size of V8 global handles.
76
+ *
77
+ * `used_global_handles_size` The value of used\_global\_handles\_size is the
78
+ * used memory size of V8 global handles.
79
+ *
80
+ * `external_memory` The value of external\_memory is the memory size of array
81
+ * buffers and external strings.
82
+ *
71
83
  * ```js
72
84
  * {
73
85
  * total_heap_size: 7326976,
@@ -80,7 +92,10 @@ declare module 'v8' {
80
92
  * peak_malloced_memory: 1127496,
81
93
  * does_zap_garbage: 0,
82
94
  * number_of_native_contexts: 1,
83
- * number_of_detached_contexts: 0
95
+ * number_of_detached_contexts: 0,
96
+ * total_global_handles_size: 8192,
97
+ * used_global_handles_size: 3296,
98
+ * external_memory: 318824
84
99
  * }
85
100
  * ```
86
101
  * @since v1.0.0
@@ -149,7 +164,7 @@ declare module 'v8' {
149
164
  *
150
165
  * ```js
151
166
  * // Print GC events to stdout for one minute.
152
- * const v8 = require('v8');
167
+ * const v8 = require('node:v8');
153
168
  * v8.setFlagsFromString('--trace_gc');
154
169
  * setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
155
170
  * ```
@@ -172,12 +187,12 @@ declare module 'v8' {
172
187
  *
173
188
  * ```js
174
189
  * // Print heap snapshot to the console
175
- * const v8 = require('v8');
190
+ * const v8 = require('node:v8');
176
191
  * const stream = v8.getHeapSnapshot();
177
192
  * stream.pipe(process.stdout);
178
193
  * ```
179
194
  * @since v11.13.0
180
- * @return A Readable Stream containing the V8 heap snapshot
195
+ * @return A Readable containing the V8 heap snapshot.
181
196
  */
182
197
  function getHeapSnapshot(): Readable;
183
198
  /**
@@ -197,12 +212,12 @@ declare module 'v8' {
197
212
  * for a duration depending on the heap size.
198
213
  *
199
214
  * ```js
200
- * const { writeHeapSnapshot } = require('v8');
215
+ * const { writeHeapSnapshot } = require('node:v8');
201
216
  * const {
202
217
  * Worker,
203
218
  * isMainThread,
204
- * parentPort
205
- * } = require('worker_threads');
219
+ * parentPort,
220
+ * } = require('node:worker_threads');
206
221
  *
207
222
  * if (isMainThread) {
208
223
  * const worker = new Worker(__filename);
@@ -233,13 +248,16 @@ declare module 'v8' {
233
248
  */
234
249
  function writeHeapSnapshot(filename?: string): string;
235
250
  /**
236
- * Returns an object with the following properties:
251
+ * Get statistics about code and its metadata in the heap, see
252
+ * V8[`GetHeapCodeAndMetadataStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866) API. Returns an object with the
253
+ * following properties:
237
254
  *
238
255
  * ```js
239
256
  * {
240
257
  * code_and_metadata_size: 212208,
241
258
  * bytecode_and_metadata_size: 161368,
242
- * external_script_source_size: 1410794
259
+ * external_script_source_size: 1410794,
260
+ * cpu_profiler_metadata_size: 0,
243
261
  * }
244
262
  * ```
245
263
  * @since v12.8.0
@@ -289,7 +307,7 @@ declare module 'v8' {
289
307
  */
290
308
  writeDouble(value: number): void;
291
309
  /**
292
- * Write raw bytes into the serializers internal buffer. The deserializer
310
+ * Write raw bytes into the serializer's internal buffer. The deserializer
293
311
  * will require a way to compute the length of the buffer.
294
312
  * For use inside of a custom `serializer._writeHostObject()`.
295
313
  */
@@ -345,7 +363,7 @@ declare module 'v8' {
345
363
  */
346
364
  readDouble(): number;
347
365
  /**
348
- * Read raw bytes from the deserializers internal buffer. The `length` parameter
366
+ * Read raw bytes from the deserializer's internal buffer. The `length` parameter
349
367
  * must correspond to the length of the buffer that was passed to `serializer.writeRawBytes()`.
350
368
  * For use inside of a custom `deserializer._readHostObject()`.
351
369
  */
@@ -390,6 +408,227 @@ declare module 'v8' {
390
408
  * @since v15.1.0, v14.18.0, v12.22.0
391
409
  */
392
410
  function stopCoverage(): void;
411
+ /**
412
+ * This API collects GC data in current thread.
413
+ * @since v19.6.0, v18.15.0
414
+ */
415
+ class GCProfiler {
416
+ /**
417
+ * Start collecting GC data.
418
+ * @since v19.6.0, v18.15.0
419
+ */
420
+ start(): void;
421
+ /**
422
+ * Stop collecting GC data and return an object.The content of object
423
+ * is as follows.
424
+ *
425
+ * ```json
426
+ * {
427
+ * "version": 1,
428
+ * "startTime": 1674059033862,
429
+ * "statistics": [
430
+ * {
431
+ * "gcType": "Scavenge",
432
+ * "beforeGC": {
433
+ * "heapStatistics": {
434
+ * "totalHeapSize": 5005312,
435
+ * "totalHeapSizeExecutable": 524288,
436
+ * "totalPhysicalSize": 5226496,
437
+ * "totalAvailableSize": 4341325216,
438
+ * "totalGlobalHandlesSize": 8192,
439
+ * "usedGlobalHandlesSize": 2112,
440
+ * "usedHeapSize": 4883840,
441
+ * "heapSizeLimit": 4345298944,
442
+ * "mallocedMemory": 254128,
443
+ * "externalMemory": 225138,
444
+ * "peakMallocedMemory": 181760
445
+ * },
446
+ * "heapSpaceStatistics": [
447
+ * {
448
+ * "spaceName": "read_only_space",
449
+ * "spaceSize": 0,
450
+ * "spaceUsedSize": 0,
451
+ * "spaceAvailableSize": 0,
452
+ * "physicalSpaceSize": 0
453
+ * }
454
+ * ]
455
+ * },
456
+ * "cost": 1574.14,
457
+ * "afterGC": {
458
+ * "heapStatistics": {
459
+ * "totalHeapSize": 6053888,
460
+ * "totalHeapSizeExecutable": 524288,
461
+ * "totalPhysicalSize": 5500928,
462
+ * "totalAvailableSize": 4341101384,
463
+ * "totalGlobalHandlesSize": 8192,
464
+ * "usedGlobalHandlesSize": 2112,
465
+ * "usedHeapSize": 4059096,
466
+ * "heapSizeLimit": 4345298944,
467
+ * "mallocedMemory": 254128,
468
+ * "externalMemory": 225138,
469
+ * "peakMallocedMemory": 181760
470
+ * },
471
+ * "heapSpaceStatistics": [
472
+ * {
473
+ * "spaceName": "read_only_space",
474
+ * "spaceSize": 0,
475
+ * "spaceUsedSize": 0,
476
+ * "spaceAvailableSize": 0,
477
+ * "physicalSpaceSize": 0
478
+ * }
479
+ * ]
480
+ * }
481
+ * }
482
+ * ],
483
+ * "endTime": 1674059036865
484
+ * }
485
+ * ```
486
+ *
487
+ * Here's an example.
488
+ *
489
+ * ```js
490
+ * const { GCProfiler } = require('v8');
491
+ * const profiler = new GCProfiler();
492
+ * profiler.start();
493
+ * setTimeout(() => {
494
+ * console.log(profiler.stop());
495
+ * }, 1000);
496
+ * ```
497
+ * @since v19.6.0, v18.15.0
498
+ */
499
+ stop(): GCProfilerResult;
500
+ }
501
+ interface GCProfilerResult {
502
+ version: number;
503
+ startTime: number;
504
+ endTime: number;
505
+ statistics: Array<{
506
+ gcType: string;
507
+ cost: number;
508
+ beforeGC: {
509
+ heapStatistics: HeapStatistics;
510
+ heapSpaceStatistics: HeapSpaceStatistics[];
511
+ };
512
+ afterGC: {
513
+ heapStatistics: HeapStatistics;
514
+ heapSpaceStatistics: HeapSpaceStatistics[];
515
+ };
516
+ }>;
517
+ }
518
+ interface HeapStatistics {
519
+ totalHeapSize: number;
520
+ totalHeapSizeExecutable: number;
521
+ totalPhysicalSize: number;
522
+ totalAvailableSize: number;
523
+ totalGlobalHandlesSize: number;
524
+ usedGlobalHandlesSize: number;
525
+ usedHeapSize: number;
526
+ heapSizeLimit: number;
527
+ mallocedMemory: number;
528
+ externalMemory: number;
529
+ peakMallocedMemory: number;
530
+ }
531
+ interface HeapSpaceStatistics {
532
+ spaceName: string;
533
+ spaceSize: number;
534
+ spaceUsedSize: number;
535
+ spaceAvailableSize: number;
536
+ physicalSpaceSize: number;
537
+ }
538
+ /**
539
+ * Called when a promise is constructed. This does not mean that corresponding before/after events will occur, only that the possibility exists. This will
540
+ * happen if a promise is created without ever getting a continuation.
541
+ * @since v17.1.0, v16.14.0
542
+ * @param promise The promise being created.
543
+ * @param parent The promise continued from, if applicable.
544
+ */
545
+ interface Init {
546
+ (promise: Promise<unknown>, parent: Promise<unknown>): void;
547
+ }
548
+ /**
549
+ * Called before a promise continuation executes. This can be in the form of `then()`, `catch()`, or `finally()` handlers or an await resuming.
550
+ *
551
+ * The before callback will be called 0 to N times. The before callback will typically be called 0 times if no continuation was ever made for the promise.
552
+ * The before callback may be called many times in the case where many continuations have been made from the same promise.
553
+ * @since v17.1.0, v16.14.0
554
+ */
555
+ interface Before {
556
+ (promise: Promise<unknown>): void;
557
+ }
558
+ /**
559
+ * Called immediately after a promise continuation executes. This may be after a `then()`, `catch()`, or `finally()` handler or before an await after another await.
560
+ * @since v17.1.0, v16.14.0
561
+ */
562
+ interface After {
563
+ (promise: Promise<unknown>): void;
564
+ }
565
+ /**
566
+ * Called when the promise receives a resolution or rejection value. This may occur synchronously in the case of {@link Promise.resolve()} or
567
+ * {@link Promise.reject()}.
568
+ * @since v17.1.0, v16.14.0
569
+ */
570
+ interface Settled {
571
+ (promise: Promise<unknown>): void;
572
+ }
573
+ /**
574
+ * Key events in the lifetime of a promise have been categorized into four areas: creation of a promise, before/after a continuation handler is called or
575
+ * around an await, and when the promise resolves or rejects.
576
+ *
577
+ * Because promises are asynchronous resources whose lifecycle is tracked via the promise hooks mechanism, the `init()`, `before()`, `after()`, and
578
+ * `settled()` callbacks must not be async functions as they create more promises which would produce an infinite loop.
579
+ * @since v17.1.0, v16.14.0
580
+ */
581
+ interface HookCallbacks {
582
+ init?: Init;
583
+ before?: Before;
584
+ after?: After;
585
+ settled?: Settled;
586
+ }
587
+ interface PromiseHooks {
588
+ /**
589
+ * The `init` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
590
+ * @since v17.1.0, v16.14.0
591
+ * @param init The {@link Init | `init` callback} to call when a promise is created.
592
+ * @return Call to stop the hook.
593
+ */
594
+ onInit: (init: Init) => Function;
595
+ /**
596
+ * The `settled` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
597
+ * @since v17.1.0, v16.14.0
598
+ * @param settled The {@link Settled | `settled` callback} to call when a promise is created.
599
+ * @return Call to stop the hook.
600
+ */
601
+ onSettled: (settled: Settled) => Function;
602
+ /**
603
+ * The `before` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
604
+ * @since v17.1.0, v16.14.0
605
+ * @param before The {@link Before | `before` callback} to call before a promise continuation executes.
606
+ * @return Call to stop the hook.
607
+ */
608
+ onBefore: (before: Before) => Function;
609
+ /**
610
+ * The `after` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
611
+ * @since v17.1.0, v16.14.0
612
+ * @param after The {@link After | `after` callback} to call after a promise continuation executes.
613
+ * @return Call to stop the hook.
614
+ */
615
+ onAfter: (after: After) => Function;
616
+ /**
617
+ * Registers functions to be called for different lifetime events of each promise.
618
+ * The callbacks `init()`/`before()`/`after()`/`settled()` are called for the respective events during a promise's lifetime.
619
+ * All callbacks are optional. For example, if only promise creation needs to be tracked, then only the init callback needs to be passed.
620
+ * The hook callbacks must be plain functions. Providing async functions will throw as it would produce an infinite microtask loop.
621
+ * @since v17.1.0, v16.14.0
622
+ * @param callbacks The {@link HookCallbacks | Hook Callbacks} to register
623
+ * @return Used for disabling hooks
624
+ */
625
+ createHook: (callbacks: HookCallbacks) => Function;
626
+ }
627
+ /**
628
+ * The `promiseHooks` interface can be used to track promise lifecycle events.
629
+ * @since v17.1.0, v16.14.0
630
+ */
631
+ const promiseHooks: PromiseHooks;
393
632
  }
394
633
  declare module 'node:v8' {
395
634
  export * from 'v8';