@types/node 20.14.4 → 20.14.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 (3) hide show
  1. node/README.md +1 -1
  2. node/events.d.ts +39 -1
  3. node/package.json +2 -2
node/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for node (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: Mon, 17 Jun 2024 23:07:28 GMT
11
+ * Last updated: Tue, 18 Jun 2024 06:37:41 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
node/events.d.ts CHANGED
@@ -98,6 +98,22 @@ declare module "events" {
98
98
  */
99
99
  lowWaterMark?: number | undefined;
100
100
  }
101
+ interface StaticEventEmitterIteratorOptions extends StaticEventEmitterOptions {
102
+ /**
103
+ * Names of events that will end the iteration.
104
+ */
105
+ close?: string[];
106
+ /**
107
+ * The emitter is paused every time the size of events being buffered is higher than it. Supported only on emitters implementing pause() and resume() methods.
108
+ * @default Number.MAX_SAFE_INTEGER
109
+ */
110
+ highWaterMark?: number;
111
+ /**
112
+ * The emitter is resumed every time the size of events being buffered is lower than it. Supported only on emitters implementing pause() and resume() methods.
113
+ * @default 1
114
+ */
115
+ lowWaterMark?: number;
116
+ }
101
117
  interface EventEmitter<T extends EventMap<T> = DefaultEventMap> extends NodeJS.EventEmitter<T> {}
102
118
  type EventMap<T> = Record<keyof T, any[]> | DefaultEventMap;
103
119
  type DefaultEventMap = [never];
@@ -274,6 +290,28 @@ declare module "events" {
274
290
  *
275
291
  * process.nextTick(() => ac.abort());
276
292
  * ```
293
+ *
294
+ * Use the `close` option to specify an array of event names that will end the iteration:
295
+ *
296
+ * ```js
297
+ * import { on, EventEmitter } from 'node:events';
298
+ * import process from 'node:process';
299
+ *
300
+ * const ee = new EventEmitter();
301
+ *
302
+ * // Emit later on
303
+ * process.nextTick(() => {
304
+ * ee.emit('foo', 'bar');
305
+ * ee.emit('foo', 42);
306
+ * ee.emit('close');
307
+ * });
308
+ *
309
+ * for await (const event of on(ee, 'foo', { close: ['close'] })) {
310
+ * console.log(event); // prints ['bar'] [42]
311
+ * }
312
+ * // the loop will exit after 'close' is emitted
313
+ * console.log('done'); // prints 'done'
314
+ * ```
277
315
  * @since v13.6.0, v12.16.0
278
316
  * @param eventName The name of the event being listened for
279
317
  * @return An `AsyncIterator` that iterates `eventName` events emitted by the `emitter`
@@ -286,7 +324,7 @@ declare module "events" {
286
324
  static on(
287
325
  emitter: EventTarget,
288
326
  eventName: string,
289
- options?: StaticEventEmitterOptions,
327
+ options?: StaticEventEmitterIteratorOptions,
290
328
  ): AsyncIterableIterator<any>;
291
329
  /**
292
330
  * A class method that returns the number of listeners for the given `eventName` registered on the given `emitter`.
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "20.14.4",
3
+ "version": "20.14.5",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -212,6 +212,6 @@
212
212
  "dependencies": {
213
213
  "undici-types": "~5.26.4"
214
214
  },
215
- "typesPublisherContentHash": "51d4ba5b24961c3ba56036b7cd2fe8a17897079f173eb00cc8cf362445289de9",
215
+ "typesPublisherContentHash": "8dc6f8d71b81b71918d54a2fc8b71f492e0c9ebb263ffe4a93970039c9aadd3b",
216
216
  "typeScriptVersion": "4.7"
217
217
  }