@types/node 20.8.0 → 20.8.1

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 (3) hide show
  1. node/README.md +1 -1
  2. node/events.d.ts +49 -0
  3. node/package.json +2 -2
node/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Sat, 30 Sep 2023 08:35:04 GMT
11
+ * Last updated: Mon, 02 Oct 2023 20:06:22 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
14
14
 
node/events.d.ts CHANGED
@@ -35,6 +35,7 @@
35
35
  * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/events.js)
36
36
  */
37
37
  declare module "events" {
38
+ import { AsyncResource, AsyncResourceOptions } from "node:async_hooks";
38
39
  // NOTE: This class is in the docs but is **not actually exported** by Node.
39
40
  // If https://github.com/nodejs/node/issues/39903 gets resolved and Node
40
41
  // actually starts exporting the class, uncomment below.
@@ -107,6 +108,9 @@ declare module "events" {
107
108
  */
108
109
  class EventEmitter {
109
110
  constructor(options?: EventEmitterOptions);
111
+
112
+ [EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void;
113
+
110
114
  /**
111
115
  * Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
112
116
  * event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
@@ -451,10 +455,55 @@ declare module "events" {
451
455
  */
452
456
  signal?: AbortSignal | undefined;
453
457
  }
458
+
459
+ export interface EventEmitterReferencingAsyncResource extends AsyncResource {
460
+ readonly eventEmitter: EventEmitterAsyncResource;
461
+ }
462
+
463
+ export interface EventEmitterAsyncResourceOptions extends AsyncResourceOptions, EventEmitterOptions {
464
+ /**
465
+ * The type of async event, this is required when instantiating `EventEmitterAsyncResource`
466
+ * directly rather than as a child class.
467
+ * @default new.target.name if instantiated as a child class.
468
+ */
469
+ name?: string;
470
+ }
471
+
472
+ /**
473
+ * Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that require
474
+ * manual async tracking. Specifically, all events emitted by instances of
475
+ * `EventEmitterAsyncResource` will run within its async context.
476
+ *
477
+ * The EventEmitterAsyncResource class has the same methods and takes the
478
+ * same options as EventEmitter and AsyncResource themselves.
479
+ * @throws if `options.name` is not provided when instantiated directly.
480
+ * @since v17.4.0, v16.14.0
481
+ */
482
+ export class EventEmitterAsyncResource extends EventEmitter {
483
+ /**
484
+ * @param options Only optional in child class.
485
+ */
486
+ constructor(options?: EventEmitterAsyncResourceOptions);
487
+ /**
488
+ * Call all destroy hooks. This should only ever be called once. An
489
+ * error will be thrown if it is called more than once. This must be
490
+ * manually called. If the resource is left to be collected by the GC then
491
+ * the destroy hooks will never be called.
492
+ */
493
+ emitDestroy(): void;
494
+ /** The unique asyncId assigned to the resource. */
495
+ readonly asyncId: number;
496
+ /** The same triggerAsyncId that is passed to the AsyncResource constructor. */
497
+ readonly triggerAsyncId: number;
498
+ /** The underlying AsyncResource */
499
+ readonly asyncResource: EventEmitterReferencingAsyncResource;
500
+ }
454
501
  }
455
502
  global {
456
503
  namespace NodeJS {
457
504
  interface EventEmitter {
505
+
506
+ [EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void;
458
507
  /**
459
508
  * Alias for `emitter.on(eventName, listener)`.
460
509
  * @since v0.1.26
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "20.8.0",
3
+ "version": "20.8.1",
4
4
  "description": "TypeScript definitions for Node.js",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -227,6 +227,6 @@
227
227
  },
228
228
  "scripts": {},
229
229
  "dependencies": {},
230
- "typesPublisherContentHash": "7637ed07b3e4b1806d0b4b3e38bd788c3004f33c9700b8b65432d5894164b46f",
230
+ "typesPublisherContentHash": "9df8dc36b5df180b9e925f6a58ac11ac2a2d8851a8f5dbe6646356a90dcd886c",
231
231
  "typeScriptVersion": "4.5"
232
232
  }