@types/node 24.12.0 → 25.5.0

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 (98) hide show
  1. node v24.12/README.md → node/README.md +2 -2
  2. node v24.12/assert/strict.d.ts → node/assert/strict.d.ts +5 -11
  3. node v24.12/assert.d.ts → node/assert.d.ts +11 -171
  4. node v24.12/async_hooks.d.ts → node/async_hooks.d.ts +8 -8
  5. node v24.12/buffer.buffer.d.ts → node/buffer.buffer.d.ts +1 -7
  6. node v24.12/buffer.d.ts → node/buffer.d.ts +44 -168
  7. node v24.12/child_process.d.ts → node/child_process.d.ts +21 -64
  8. node/cluster.d.ts +486 -0
  9. node/console.d.ts +151 -0
  10. node v24.12/constants.d.ts → node/constants.d.ts +3 -4
  11. node v24.12/crypto.d.ts → node/crypto.d.ts +287 -1639
  12. node v24.12/dgram.d.ts → node/dgram.d.ts +15 -51
  13. node v24.12/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +4 -4
  14. node v24.12/dns/promises.d.ts → node/dns/promises.d.ts +3 -3
  15. node v24.12/dns.d.ts → node/dns.d.ts +131 -132
  16. node v24.12/domain.d.ts → node/domain.d.ts +13 -17
  17. node v24.12/events.d.ts → node/events.d.ts +866 -795
  18. node v24.12/fs/promises.d.ts → node/fs/promises.d.ts +7 -8
  19. node v24.12/fs.d.ts → node/fs.d.ts +419 -455
  20. node v24.12/globals.d.ts → node/globals.d.ts +6 -26
  21. node/globals.typedarray.d.ts +101 -0
  22. node v24.12/http.d.ts → node/http.d.ts +310 -276
  23. node v24.12/http2.d.ts → node/http2.d.ts +528 -804
  24. node v24.12/https.d.ts → node/https.d.ts +63 -243
  25. node v24.12/index.d.ts → node/index.d.ts +15 -1
  26. node/inspector/promises.d.ts +41 -0
  27. node v24.12/inspector.d.ts → node/inspector.d.ts +42 -50
  28. node v24.12/inspector.generated.d.ts → node/inspector.generated.d.ts +572 -417
  29. node v24.12/module.d.ts → node/module.d.ts +47 -195
  30. node v24.12/net.d.ts → node/net.d.ts +68 -189
  31. node v24.12/os.d.ts → node/os.d.ts +6 -6
  32. node v24.12/package.json → node/package.json +3 -3
  33. node/path/posix.d.ts +8 -0
  34. node/path/win32.d.ts +8 -0
  35. node/path.d.ts +187 -0
  36. node/perf_hooks.d.ts +643 -0
  37. node v24.12/process.d.ts → node/process.d.ts +219 -127
  38. node v24.12/punycode.d.ts → node/punycode.d.ts +5 -5
  39. node v24.12/querystring.d.ts → node/querystring.d.ts +4 -4
  40. node/quic.d.ts +910 -0
  41. node v24.12/readline/promises.d.ts → node/readline/promises.d.ts +3 -3
  42. node v24.12/readline.d.ts → node/readline.d.ts +68 -120
  43. node v24.12/repl.d.ts → node/repl.d.ts +75 -98
  44. node v24.12/sea.d.ts → node/sea.d.ts +1 -1
  45. node v24.12/sqlite.d.ts → node/sqlite.d.ts +137 -30
  46. node v24.12/stream/consumers.d.ts → node/stream/consumers.d.ts +10 -10
  47. node/stream/promises.d.ts +211 -0
  48. node/stream/web.d.ts +296 -0
  49. node v24.12/stream.d.ts → node/stream.d.ts +565 -478
  50. node v24.12/string_decoder.d.ts → node/string_decoder.d.ts +4 -4
  51. node/test/reporters.d.ts +96 -0
  52. node v24.12/test.d.ts → node/test.d.ts +134 -199
  53. node v24.12/timers/promises.d.ts → node/timers/promises.d.ts +4 -4
  54. node v24.12/timers.d.ts → node/timers.d.ts +4 -130
  55. node v24.12/tls.d.ts → node/tls.d.ts +109 -179
  56. node v24.12/trace_events.d.ts → node/trace_events.d.ts +9 -9
  57. node v24.12/ts5.6/buffer.buffer.d.ts → node/ts5.6/buffer.buffer.d.ts +1 -7
  58. node v24.12/ts5.6/index.d.ts → node/ts5.6/index.d.ts +15 -1
  59. node v24.12/ts5.7/index.d.ts → node/ts5.7/index.d.ts +15 -1
  60. node v24.12/tty.d.ts → node/tty.d.ts +58 -16
  61. node/url.d.ts +541 -0
  62. node/util/types.d.ts +558 -0
  63. node v24.12/util.d.ts → node/util.d.ts +150 -796
  64. node v24.12/v8.d.ts → node/v8.d.ts +31 -21
  65. node v24.12/vm.d.ts → node/vm.d.ts +43 -30
  66. node v24.12/wasi.d.ts → node/wasi.d.ts +4 -4
  67. node v24.12/web-globals/abortcontroller.d.ts → node/web-globals/abortcontroller.d.ts +27 -2
  68. node/web-globals/blob.d.ts +23 -0
  69. node/web-globals/console.d.ts +9 -0
  70. node v24.12/web-globals/crypto.d.ts → node/web-globals/crypto.d.ts +7 -0
  71. node/web-globals/encoding.d.ts +11 -0
  72. node v24.12/web-globals/events.d.ts → node/web-globals/events.d.ts +9 -0
  73. node v24.12/web-globals/fetch.d.ts → node/web-globals/fetch.d.ts +7 -0
  74. node/web-globals/importmeta.d.ts +13 -0
  75. node/web-globals/messaging.d.ts +23 -0
  76. node/web-globals/performance.d.ts +45 -0
  77. node/web-globals/streams.d.ts +115 -0
  78. node/web-globals/timers.d.ts +44 -0
  79. node/web-globals/url.d.ts +24 -0
  80. node v24.12/worker_threads.d.ts → node/worker_threads.d.ts +186 -363
  81. node v24.12/zlib.d.ts → node/zlib.d.ts +8 -71
  82. node v24.12/cluster.d.ts +0 -578
  83. node v24.12/console.d.ts +0 -453
  84. node v24.12/globals.typedarray.d.ts +0 -41
  85. node v24.12/path.d.ts +0 -200
  86. node v24.12/perf_hooks.d.ts +0 -1042
  87. node v24.12/stream/promises.d.ts +0 -90
  88. node v24.12/stream/web.d.ts +0 -573
  89. node v24.12/url.d.ts +0 -1057
  90. node v24.12/web-globals/streams.d.ts +0 -22
  91. {node v24.12 → node}/LICENSE +0 -0
  92. {node v24.12 → node}/compatibility/iterators.d.ts +0 -0
  93. {node v24.12 → node}/ts5.6/compatibility/float16array.d.ts +0 -0
  94. {node v24.12 → node}/ts5.6/globals.typedarray.d.ts +0 -0
  95. {node v24.12 → node}/ts5.7/compatibility/float16array.d.ts +0 -0
  96. {node v24.12 → node}/web-globals/domexception.d.ts +0 -0
  97. {node v24.12 → node}/web-globals/navigator.d.ts +0 -0
  98. {node v24.12 → node}/web-globals/storage.d.ts +0 -0
node/perf_hooks.d.ts ADDED
@@ -0,0 +1,643 @@
1
+ /**
2
+ * This module provides an implementation of a subset of the W3C [Web Performance APIs](https://w3c.github.io/perf-timing-primer/) as well as additional APIs for
3
+ * Node.js-specific performance measurements.
4
+ *
5
+ * Node.js supports the following [Web Performance APIs](https://w3c.github.io/perf-timing-primer/):
6
+ *
7
+ * * [High Resolution Time](https://www.w3.org/TR/hr-time-2)
8
+ * * [Performance Timeline](https://w3c.github.io/performance-timeline/)
9
+ * * [User Timing](https://www.w3.org/TR/user-timing/)
10
+ * * [Resource Timing](https://www.w3.org/TR/resource-timing-2/)
11
+ *
12
+ * ```js
13
+ * import { PerformanceObserver, performance } from 'node:perf_hooks';
14
+ *
15
+ * const obs = new PerformanceObserver((items) => {
16
+ * console.log(items.getEntries()[0].duration);
17
+ * performance.clearMarks();
18
+ * });
19
+ * obs.observe({ type: 'measure' });
20
+ * performance.measure('Start to Now');
21
+ *
22
+ * performance.mark('A');
23
+ * doSomeLongRunningProcess(() => {
24
+ * performance.measure('A to Now', 'A');
25
+ *
26
+ * performance.mark('B');
27
+ * performance.measure('A to B', 'A', 'B');
28
+ * });
29
+ * ```
30
+ * @see [source](https://github.com/nodejs/node/blob/v25.x/lib/perf_hooks.js)
31
+ */
32
+ declare module "node:perf_hooks" {
33
+ import { InternalEventTargetEventProperties } from "node:events";
34
+ // #region web types
35
+ type EntryType =
36
+ | "dns" // Node.js only
37
+ | "function" // Node.js only
38
+ | "gc" // Node.js only
39
+ | "http2" // Node.js only
40
+ | "http" // Node.js only
41
+ | "mark" // available on the Web
42
+ | "measure" // available on the Web
43
+ | "net" // Node.js only
44
+ | "node" // Node.js only
45
+ | "resource"; // available on the Web
46
+ interface ConnectionTimingInfo {
47
+ domainLookupStartTime: number;
48
+ domainLookupEndTime: number;
49
+ connectionStartTime: number;
50
+ connectionEndTime: number;
51
+ secureConnectionStartTime: number;
52
+ ALPNNegotiatedProtocol: string;
53
+ }
54
+ interface FetchTimingInfo {
55
+ startTime: number;
56
+ redirectStartTime: number;
57
+ redirectEndTime: number;
58
+ postRedirectStartTime: number;
59
+ finalServiceWorkerStartTime: number;
60
+ finalNetworkRequestStartTime: number;
61
+ finalNetworkResponseStartTime: number;
62
+ endTime: number;
63
+ finalConnectionTimingInfo: ConnectionTimingInfo | null;
64
+ encodedBodySize: number;
65
+ decodedBodySize: number;
66
+ }
67
+ type PerformanceEntryList = PerformanceEntry[];
68
+ interface PerformanceMarkOptions {
69
+ detail?: any;
70
+ startTime?: number;
71
+ }
72
+ interface PerformanceMeasureOptions {
73
+ detail?: any;
74
+ duration?: number;
75
+ end?: string | number;
76
+ start?: string | number;
77
+ }
78
+ interface PerformanceObserverCallback {
79
+ (entries: PerformanceObserverEntryList, observer: PerformanceObserver): void;
80
+ }
81
+ interface PerformanceObserverInit {
82
+ buffered?: boolean;
83
+ entryTypes?: EntryType[];
84
+ type?: EntryType;
85
+ }
86
+ // TODO: remove in next major
87
+ /** @deprecated Use `TimerifyOptions` instead. */
88
+ interface PerformanceTimerifyOptions extends TimerifyOptions {}
89
+ interface PerformanceEventMap {
90
+ "resourcetimingbufferfull": Event;
91
+ }
92
+ interface Performance extends EventTarget, InternalEventTargetEventProperties<PerformanceEventMap> {
93
+ readonly nodeTiming: PerformanceNodeTiming;
94
+ readonly timeOrigin: number;
95
+ clearMarks(markName?: string): void;
96
+ clearMeasures(measureName?: string): void;
97
+ clearResourceTimings(resourceTimingName?: string): void;
98
+ getEntries(): PerformanceEntryList;
99
+ getEntriesByName(name: string, type?: EntryType): PerformanceEntryList;
100
+ getEntriesByType(type: EntryType): PerformanceEntryList;
101
+ mark(markName: string, markOptions?: PerformanceMarkOptions): PerformanceMark;
102
+ markResourceTiming(
103
+ timingInfo: FetchTimingInfo,
104
+ requestedUrl: string,
105
+ initiatorType: string,
106
+ global: unknown,
107
+ cacheMode: string,
108
+ bodyInfo: unknown,
109
+ responseStatus: number,
110
+ deliveryType?: string,
111
+ ): PerformanceResourceTiming;
112
+ measure(measureName: string, startMark?: string, endMark?: string): PerformanceMeasure;
113
+ measure(measureName: string, options: PerformanceMeasureOptions, endMark?: string): PerformanceMeasure;
114
+ now(): number;
115
+ setResourceTimingBufferSize(maxSize: number): void;
116
+ toJSON(): any;
117
+ addEventListener<K extends keyof PerformanceEventMap>(
118
+ type: K,
119
+ listener: (ev: PerformanceEventMap[K]) => void,
120
+ options?: AddEventListenerOptions | boolean,
121
+ ): void;
122
+ addEventListener(
123
+ type: string,
124
+ listener: EventListener | EventListenerObject,
125
+ options?: AddEventListenerOptions | boolean,
126
+ ): void;
127
+ removeEventListener<K extends keyof PerformanceEventMap>(
128
+ type: K,
129
+ listener: (ev: PerformanceEventMap[K]) => void,
130
+ options?: EventListenerOptions | boolean,
131
+ ): void;
132
+ removeEventListener(
133
+ type: string,
134
+ listener: EventListener | EventListenerObject,
135
+ options?: EventListenerOptions | boolean,
136
+ ): void;
137
+ /**
138
+ * This is an alias of `perf_hooks.eventLoopUtilization()`.
139
+ *
140
+ * _This property is an extension by Node.js. It is not available in Web browsers._
141
+ * @since v14.10.0, v12.19.0
142
+ * @param utilization1 The result of a previous call to
143
+ * `eventLoopUtilization()`.
144
+ * @param utilization2 The result of a previous call to
145
+ * `eventLoopUtilization()` prior to `utilization1`.
146
+ */
147
+ eventLoopUtilization(
148
+ utilization1?: EventLoopUtilization,
149
+ utilization2?: EventLoopUtilization,
150
+ ): EventLoopUtilization;
151
+ /**
152
+ * This is an alias of `perf_hooks.timerify()`.
153
+ *
154
+ * _This property is an extension by Node.js. It is not available in Web browsers._
155
+ * @since v8.5.0
156
+ */
157
+ timerify<T extends (...args: any[]) => any>(fn: T, options?: TimerifyOptions): T;
158
+ }
159
+ var Performance: {
160
+ prototype: Performance;
161
+ new(): Performance;
162
+ };
163
+ interface PerformanceEntry {
164
+ readonly duration: number;
165
+ readonly entryType: EntryType;
166
+ readonly name: string;
167
+ readonly startTime: number;
168
+ toJSON(): any;
169
+ }
170
+ var PerformanceEntry: {
171
+ prototype: PerformanceEntry;
172
+ new(): PerformanceEntry;
173
+ };
174
+ interface PerformanceMark extends PerformanceEntry {
175
+ readonly detail: any;
176
+ readonly entryType: "mark";
177
+ }
178
+ var PerformanceMark: {
179
+ prototype: PerformanceMark;
180
+ new(markName: string, markOptions?: PerformanceMarkOptions): PerformanceMark;
181
+ };
182
+ interface PerformanceMeasure extends PerformanceEntry {
183
+ readonly detail: any;
184
+ readonly entryType: "measure";
185
+ }
186
+ var PerformanceMeasure: {
187
+ prototype: PerformanceMeasure;
188
+ new(): PerformanceMeasure;
189
+ };
190
+ interface PerformanceObserver {
191
+ disconnect(): void;
192
+ observe(options: PerformanceObserverInit): void;
193
+ takeRecords(): PerformanceEntryList;
194
+ }
195
+ var PerformanceObserver: {
196
+ prototype: PerformanceObserver;
197
+ new(callback: PerformanceObserverCallback): PerformanceObserver;
198
+ readonly supportedEntryTypes: readonly EntryType[];
199
+ };
200
+ interface PerformanceObserverEntryList {
201
+ getEntries(): PerformanceEntryList;
202
+ getEntriesByName(name: string, type?: EntryType): PerformanceEntryList;
203
+ getEntriesByType(type: EntryType): PerformanceEntryList;
204
+ }
205
+ var PerformanceObserverEntryList: {
206
+ prototype: PerformanceObserverEntryList;
207
+ new(): PerformanceObserverEntryList;
208
+ };
209
+ interface PerformanceResourceTiming extends PerformanceEntry {
210
+ readonly connectEnd: number;
211
+ readonly connectStart: number;
212
+ readonly decodedBodySize: number;
213
+ readonly domainLookupEnd: number;
214
+ readonly domainLookupStart: number;
215
+ readonly encodedBodySize: number;
216
+ readonly entryType: "resource";
217
+ readonly fetchStart: number;
218
+ readonly initiatorType: string;
219
+ readonly nextHopProtocol: string;
220
+ readonly redirectEnd: number;
221
+ readonly redirectStart: number;
222
+ readonly requestStart: number;
223
+ readonly responseEnd: number;
224
+ readonly responseStart: number;
225
+ readonly responseStatus: number;
226
+ readonly secureConnectionStart: number;
227
+ readonly transferSize: number;
228
+ readonly workerStart: number;
229
+ toJSON(): any;
230
+ }
231
+ var PerformanceResourceTiming: {
232
+ prototype: PerformanceResourceTiming;
233
+ new(): PerformanceResourceTiming;
234
+ };
235
+ var performance: Performance;
236
+ // #endregion
237
+ /**
238
+ * _This class is an extension by Node.js. It is not available in Web browsers._
239
+ *
240
+ * Provides detailed Node.js timing data.
241
+ *
242
+ * The constructor of this class is not exposed to users directly.
243
+ * @since v19.0.0
244
+ */
245
+ class PerformanceNodeEntry extends PerformanceEntry {
246
+ /**
247
+ * Additional detail specific to the `entryType`.
248
+ * @since v16.0.0
249
+ */
250
+ readonly detail: any;
251
+ readonly entryType: "dns" | "function" | "gc" | "http2" | "http" | "net" | "node";
252
+ }
253
+ interface UVMetrics {
254
+ /**
255
+ * Number of event loop iterations.
256
+ */
257
+ readonly loopCount: number;
258
+ /**
259
+ * Number of events that have been processed by the event handler.
260
+ */
261
+ readonly events: number;
262
+ /**
263
+ * Number of events that were waiting to be processed when the event provider was called.
264
+ */
265
+ readonly eventsWaiting: number;
266
+ }
267
+ /**
268
+ * _This property is an extension by Node.js. It is not available in Web browsers._
269
+ *
270
+ * Provides timing details for Node.js itself. The constructor of this class
271
+ * is not exposed to users.
272
+ * @since v8.5.0
273
+ */
274
+ interface PerformanceNodeTiming extends PerformanceEntry {
275
+ /**
276
+ * The high resolution millisecond timestamp at which the Node.js process
277
+ * completed bootstrapping. If bootstrapping has not yet finished, the property
278
+ * has the value of -1.
279
+ * @since v8.5.0
280
+ */
281
+ readonly bootstrapComplete: number;
282
+ readonly entryType: "node";
283
+ /**
284
+ * The high resolution millisecond timestamp at which the Node.js environment was
285
+ * initialized.
286
+ * @since v8.5.0
287
+ */
288
+ readonly environment: number;
289
+ /**
290
+ * The high resolution millisecond timestamp of the amount of time the event loop
291
+ * has been idle within the event loop's event provider (e.g. `epoll_wait`). This
292
+ * does not take CPU usage into consideration. If the event loop has not yet
293
+ * started (e.g., in the first tick of the main script), the property has the
294
+ * value of 0.
295
+ * @since v14.10.0, v12.19.0
296
+ */
297
+ readonly idleTime: number;
298
+ /**
299
+ * The high resolution millisecond timestamp at which the Node.js event loop
300
+ * exited. If the event loop has not yet exited, the property has the value of -1\.
301
+ * It can only have a value of not -1 in a handler of the `'exit'` event.
302
+ * @since v8.5.0
303
+ */
304
+ readonly loopExit: number;
305
+ /**
306
+ * The high resolution millisecond timestamp at which the Node.js event loop
307
+ * started. If the event loop has not yet started (e.g., in the first tick of the
308
+ * main script), the property has the value of -1.
309
+ * @since v8.5.0
310
+ */
311
+ readonly loopStart: number;
312
+ /**
313
+ * The high resolution millisecond timestamp at which the Node.js process was initialized.
314
+ * @since v8.5.0
315
+ */
316
+ readonly nodeStart: number;
317
+ /**
318
+ * This is a wrapper to the `uv_metrics_info` function.
319
+ * It returns the current set of event loop metrics.
320
+ *
321
+ * It is recommended to use this property inside a function whose execution was
322
+ * scheduled using `setImmediate` to avoid collecting metrics before finishing all
323
+ * operations scheduled during the current loop iteration.
324
+ * @since v22.8.0, v20.18.0
325
+ */
326
+ readonly uvMetricsInfo: UVMetrics;
327
+ /**
328
+ * The high resolution millisecond timestamp at which the V8 platform was
329
+ * initialized.
330
+ * @since v8.5.0
331
+ */
332
+ readonly v8Start: number;
333
+ }
334
+ namespace constants {
335
+ const NODE_PERFORMANCE_GC_MAJOR: number;
336
+ const NODE_PERFORMANCE_GC_MINOR: number;
337
+ const NODE_PERFORMANCE_GC_INCREMENTAL: number;
338
+ const NODE_PERFORMANCE_GC_WEAKCB: number;
339
+ const NODE_PERFORMANCE_GC_FLAGS_NO: number;
340
+ const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number;
341
+ const NODE_PERFORMANCE_GC_FLAGS_FORCED: number;
342
+ const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number;
343
+ const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number;
344
+ const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number;
345
+ const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number;
346
+ }
347
+ interface EventLoopMonitorOptions {
348
+ /**
349
+ * The sampling rate in milliseconds.
350
+ * Must be greater than zero.
351
+ * @default 10
352
+ */
353
+ resolution?: number | undefined;
354
+ }
355
+ interface Histogram {
356
+ /**
357
+ * The number of samples recorded by the histogram.
358
+ * @since v17.4.0, v16.14.0
359
+ */
360
+ readonly count: number;
361
+ /**
362
+ * The number of samples recorded by the histogram.
363
+ * v17.4.0, v16.14.0
364
+ */
365
+ readonly countBigInt: bigint;
366
+ /**
367
+ * The number of times the event loop delay exceeded the maximum 1 hour event
368
+ * loop delay threshold.
369
+ * @since v11.10.0
370
+ */
371
+ readonly exceeds: number;
372
+ /**
373
+ * The number of times the event loop delay exceeded the maximum 1 hour event loop delay threshold.
374
+ * @since v17.4.0, v16.14.0
375
+ */
376
+ readonly exceedsBigInt: bigint;
377
+ /**
378
+ * The maximum recorded event loop delay.
379
+ * @since v11.10.0
380
+ */
381
+ readonly max: number;
382
+ /**
383
+ * The maximum recorded event loop delay.
384
+ * v17.4.0, v16.14.0
385
+ */
386
+ readonly maxBigInt: number;
387
+ /**
388
+ * The mean of the recorded event loop delays.
389
+ * @since v11.10.0
390
+ */
391
+ readonly mean: number;
392
+ /**
393
+ * The minimum recorded event loop delay.
394
+ * @since v11.10.0
395
+ */
396
+ readonly min: number;
397
+ /**
398
+ * The minimum recorded event loop delay.
399
+ * v17.4.0, v16.14.0
400
+ */
401
+ readonly minBigInt: bigint;
402
+ /**
403
+ * Returns the value at the given percentile.
404
+ * @since v11.10.0
405
+ * @param percentile A percentile value in the range (0, 100].
406
+ */
407
+ percentile(percentile: number): number;
408
+ /**
409
+ * Returns the value at the given percentile.
410
+ * @since v17.4.0, v16.14.0
411
+ * @param percentile A percentile value in the range (0, 100].
412
+ */
413
+ percentileBigInt(percentile: number): bigint;
414
+ /**
415
+ * Returns a `Map` object detailing the accumulated percentile distribution.
416
+ * @since v11.10.0
417
+ */
418
+ readonly percentiles: Map<number, number>;
419
+ /**
420
+ * Returns a `Map` object detailing the accumulated percentile distribution.
421
+ * @since v17.4.0, v16.14.0
422
+ */
423
+ readonly percentilesBigInt: Map<bigint, bigint>;
424
+ /**
425
+ * Resets the collected histogram data.
426
+ * @since v11.10.0
427
+ */
428
+ reset(): void;
429
+ /**
430
+ * The standard deviation of the recorded event loop delays.
431
+ * @since v11.10.0
432
+ */
433
+ readonly stddev: number;
434
+ }
435
+ interface IntervalHistogram extends Histogram {
436
+ /**
437
+ * Enables the update interval timer. Returns `true` if the timer was
438
+ * started, `false` if it was already started.
439
+ * @since v11.10.0
440
+ */
441
+ enable(): boolean;
442
+ /**
443
+ * Disables the update interval timer. Returns `true` if the timer was
444
+ * stopped, `false` if it was already stopped.
445
+ * @since v11.10.0
446
+ */
447
+ disable(): boolean;
448
+ /**
449
+ * Disables the update interval timer when the histogram is disposed.
450
+ *
451
+ * ```js
452
+ * const { monitorEventLoopDelay } = require('node:perf_hooks');
453
+ * {
454
+ * using hist = monitorEventLoopDelay({ resolution: 20 });
455
+ * hist.enable();
456
+ * // The histogram will be disabled when the block is exited.
457
+ * }
458
+ * ```
459
+ * @since v24.2.0
460
+ */
461
+ [Symbol.dispose](): void;
462
+ }
463
+ interface RecordableHistogram extends Histogram {
464
+ /**
465
+ * @since v15.9.0, v14.18.0
466
+ * @param val The amount to record in the histogram.
467
+ */
468
+ record(val: number | bigint): void;
469
+ /**
470
+ * Calculates the amount of time (in nanoseconds) that has passed since the
471
+ * previous call to `recordDelta()` and records that amount in the histogram.
472
+ * @since v15.9.0, v14.18.0
473
+ */
474
+ recordDelta(): void;
475
+ /**
476
+ * Adds the values from `other` to this histogram.
477
+ * @since v17.4.0, v16.14.0
478
+ */
479
+ add(other: RecordableHistogram): void;
480
+ }
481
+ interface EventLoopUtilization {
482
+ idle: number;
483
+ active: number;
484
+ utilization: number;
485
+ }
486
+ /**
487
+ * The `eventLoopUtilization()` function returns an object that contains the
488
+ * cumulative duration of time the event loop has been both idle and active as a
489
+ * high resolution milliseconds timer. The `utilization` value is the calculated
490
+ * Event Loop Utilization (ELU).
491
+ *
492
+ * If bootstrapping has not yet finished on the main thread the properties have
493
+ * the value of `0`. The ELU is immediately available on [Worker threads](https://nodejs.org/docs/latest-v25.x/api/worker_threads.html#worker-threads) since
494
+ * bootstrap happens within the event loop.
495
+ *
496
+ * Both `utilization1` and `utilization2` are optional parameters.
497
+ *
498
+ * If `utilization1` is passed, then the delta between the current call's `active`
499
+ * and `idle` times, as well as the corresponding `utilization` value are
500
+ * calculated and returned (similar to `process.hrtime()`).
501
+ *
502
+ * If `utilization1` and `utilization2` are both passed, then the delta is
503
+ * calculated between the two arguments. This is a convenience option because,
504
+ * unlike `process.hrtime()`, calculating the ELU is more complex than a
505
+ * single subtraction.
506
+ *
507
+ * ELU is similar to CPU utilization, except that it only measures event loop
508
+ * statistics and not CPU usage. It represents the percentage of time the event
509
+ * loop has spent outside the event loop's event provider (e.g. `epoll_wait`).
510
+ * No other CPU idle time is taken into consideration. The following is an example
511
+ * of how a mostly idle process will have a high ELU.
512
+ *
513
+ * ```js
514
+ * import { eventLoopUtilization } from 'node:perf_hooks';
515
+ * import { spawnSync } from 'node:child_process';
516
+ *
517
+ * setImmediate(() => {
518
+ * const elu = eventLoopUtilization();
519
+ * spawnSync('sleep', ['5']);
520
+ * console.log(eventLoopUtilization(elu).utilization);
521
+ * });
522
+ * ```
523
+ *
524
+ * Although the CPU is mostly idle while running this script, the value of
525
+ * `utilization` is `1`. This is because the call to
526
+ * `child_process.spawnSync()` blocks the event loop from proceeding.
527
+ *
528
+ * Passing in a user-defined object instead of the result of a previous call to
529
+ * `eventLoopUtilization()` will lead to undefined behavior. The return values
530
+ * are not guaranteed to reflect any correct state of the event loop.
531
+ * @since v25.2.0
532
+ * @param utilization1 The result of a previous call to
533
+ * `eventLoopUtilization()`.
534
+ * @param utilization2 The result of a previous call to
535
+ * `eventLoopUtilization()` prior to `utilization1`.
536
+ */
537
+ function eventLoopUtilization(
538
+ utilization1?: EventLoopUtilization,
539
+ utilization2?: EventLoopUtilization,
540
+ ): EventLoopUtilization;
541
+ /**
542
+ * _This property is an extension by Node.js. It is not available in Web browsers._
543
+ *
544
+ * Creates an `IntervalHistogram` object that samples and reports the event loop
545
+ * delay over time. The delays will be reported in nanoseconds.
546
+ *
547
+ * Using a timer to detect approximate event loop delay works because the
548
+ * execution of timers is tied specifically to the lifecycle of the libuv
549
+ * event loop. That is, a delay in the loop will cause a delay in the execution
550
+ * of the timer, and those delays are specifically what this API is intended to
551
+ * detect.
552
+ *
553
+ * ```js
554
+ * import { monitorEventLoopDelay } from 'node:perf_hooks';
555
+ * const h = monitorEventLoopDelay({ resolution: 20 });
556
+ * h.enable();
557
+ * // Do something.
558
+ * h.disable();
559
+ * console.log(h.min);
560
+ * console.log(h.max);
561
+ * console.log(h.mean);
562
+ * console.log(h.stddev);
563
+ * console.log(h.percentiles);
564
+ * console.log(h.percentile(50));
565
+ * console.log(h.percentile(99));
566
+ * ```
567
+ * @since v11.10.0
568
+ */
569
+ function monitorEventLoopDelay(options?: EventLoopMonitorOptions): IntervalHistogram;
570
+ interface TimerifyOptions {
571
+ /**
572
+ * A histogram object created using
573
+ * `perf_hooks.createHistogram()` that will record runtime durations in
574
+ * nanoseconds.
575
+ */
576
+ histogram?: RecordableHistogram | undefined;
577
+ }
578
+ /**
579
+ * _This property is an extension by Node.js. It is not available in Web browsers._
580
+ *
581
+ * Wraps a function within a new function that measures the running time of the
582
+ * wrapped function. A `PerformanceObserver` must be subscribed to the `'function'`
583
+ * event type in order for the timing details to be accessed.
584
+ *
585
+ * ```js
586
+ * import { timerify, performance, PerformanceObserver } from 'node:perf_hooks';
587
+ *
588
+ * function someFunction() {
589
+ * console.log('hello world');
590
+ * }
591
+ *
592
+ * const wrapped = timerify(someFunction);
593
+ *
594
+ * const obs = new PerformanceObserver((list) => {
595
+ * console.log(list.getEntries()[0].duration);
596
+ *
597
+ * performance.clearMarks();
598
+ * performance.clearMeasures();
599
+ * obs.disconnect();
600
+ * });
601
+ * obs.observe({ entryTypes: ['function'] });
602
+ *
603
+ * // A performance timeline entry will be created
604
+ * wrapped();
605
+ * ```
606
+ *
607
+ * If the wrapped function returns a promise, a finally handler will be attached
608
+ * to the promise and the duration will be reported once the finally handler is
609
+ * invoked.
610
+ * @since v25.2.0
611
+ */
612
+ function timerify<T extends (...args: any[]) => any>(fn: T, options?: TimerifyOptions): T;
613
+ interface CreateHistogramOptions {
614
+ /**
615
+ * The minimum recordable value. Must be an integer value greater than 0.
616
+ * @default 1
617
+ */
618
+ lowest?: number | bigint | undefined;
619
+ /**
620
+ * The maximum recordable value. Must be an integer value greater than min.
621
+ * @default Number.MAX_SAFE_INTEGER
622
+ */
623
+ highest?: number | bigint | undefined;
624
+ /**
625
+ * The number of accuracy digits. Must be a number between 1 and 5.
626
+ * @default 3
627
+ */
628
+ figures?: number | undefined;
629
+ }
630
+ /**
631
+ * Returns a `RecordableHistogram`.
632
+ * @since v15.9.0, v14.18.0
633
+ */
634
+ function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
635
+ // TODO: remove these in a future major
636
+ /** @deprecated Use the canonical `PerformanceMarkOptions` instead. */
637
+ interface MarkOptions extends PerformanceMarkOptions {}
638
+ /** @deprecated Use the canonical `PerformanceMeasureOptions` instead. */
639
+ interface MeasureOptions extends PerformanceMeasureOptions {}
640
+ }
641
+ declare module "perf_hooks" {
642
+ export * from "node:perf_hooks";
643
+ }