@types/node 20.8.0 → 20.8.2
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.
- node/README.md +1 -1
- node/events.d.ts +49 -0
- node/package.json +2 -2
- node/stream/consumers.d.ts +5 -5
- node/ts4.8/stream/consumers.d.ts +5 -5
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:
|
|
11
|
+
* Last updated: Mon, 02 Oct 2023 21:06:31 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.
|
|
3
|
+
"version": "20.8.2",
|
|
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": "
|
|
230
|
+
"typesPublisherContentHash": "6fe03076f21a2582000286d4d4d3451cf25369d7fcdb3e021c336aa70cfc3f68",
|
|
231
231
|
"typeScriptVersion": "4.5"
|
|
232
232
|
}
|
node/stream/consumers.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
declare module "stream/consumers" {
|
|
2
2
|
import { Blob as NodeBlob } from "node:buffer";
|
|
3
3
|
import { Readable } from "node:stream";
|
|
4
|
-
function buffer(stream: NodeJS.ReadableStream | Readable |
|
|
5
|
-
function text(stream: NodeJS.ReadableStream | Readable |
|
|
6
|
-
function arrayBuffer(stream: NodeJS.ReadableStream | Readable |
|
|
7
|
-
function blob(stream: NodeJS.ReadableStream | Readable |
|
|
8
|
-
function json(stream: NodeJS.ReadableStream | Readable |
|
|
4
|
+
function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<Buffer>;
|
|
5
|
+
function text(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<string>;
|
|
6
|
+
function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<ArrayBuffer>;
|
|
7
|
+
function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<NodeBlob>;
|
|
8
|
+
function json(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<unknown>;
|
|
9
9
|
}
|
|
10
10
|
declare module "node:stream/consumers" {
|
|
11
11
|
export * from "stream/consumers";
|
node/ts4.8/stream/consumers.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
declare module "stream/consumers" {
|
|
2
2
|
import { Blob as NodeBlob } from "node:buffer";
|
|
3
3
|
import { Readable } from "node:stream";
|
|
4
|
-
function buffer(stream: NodeJS.ReadableStream | Readable |
|
|
5
|
-
function text(stream: NodeJS.ReadableStream | Readable |
|
|
6
|
-
function arrayBuffer(stream: NodeJS.ReadableStream | Readable |
|
|
7
|
-
function blob(stream: NodeJS.ReadableStream | Readable |
|
|
8
|
-
function json(stream: NodeJS.ReadableStream | Readable |
|
|
4
|
+
function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<Buffer>;
|
|
5
|
+
function text(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<string>;
|
|
6
|
+
function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<ArrayBuffer>;
|
|
7
|
+
function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<NodeBlob>;
|
|
8
|
+
function json(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<unknown>;
|
|
9
9
|
}
|
|
10
10
|
declare module "node:stream/consumers" {
|
|
11
11
|
export * from "stream/consumers";
|