1 | /// <reference types="node" />
|
---|
2 | import { EventEmitter } from 'events';
|
---|
3 | import { AsyncResource } from 'async_hooks';
|
---|
4 | declare const kEventEmitter: unique symbol;
|
---|
5 | declare const kAsyncResource: unique symbol;
|
---|
6 | declare type EventEmitterOptions = typeof EventEmitter extends {
|
---|
7 | new (options?: infer T): EventEmitter;
|
---|
8 | } ? T : never;
|
---|
9 | declare type AsyncResourceOptions = typeof AsyncResource extends {
|
---|
10 | new (name: string, options?: infer T): AsyncResource;
|
---|
11 | } ? T : never;
|
---|
12 | declare type Options = EventEmitterOptions & AsyncResourceOptions & {
|
---|
13 | name?: string;
|
---|
14 | };
|
---|
15 | declare class EventEmitterReferencingAsyncResource extends AsyncResource {
|
---|
16 | [kEventEmitter]: EventEmitter;
|
---|
17 | constructor(ee: EventEmitter, type: string, options?: AsyncResourceOptions);
|
---|
18 | get eventEmitter(): EventEmitter;
|
---|
19 | }
|
---|
20 | declare class EventEmitterAsyncResource extends EventEmitter {
|
---|
21 | [kAsyncResource]: EventEmitterReferencingAsyncResource;
|
---|
22 | constructor(options?: Options | string);
|
---|
23 | emit(event: string | symbol, ...args: any[]): boolean;
|
---|
24 | emitDestroy(): void;
|
---|
25 | asyncId(): number;
|
---|
26 | triggerAsyncId(): number;
|
---|
27 | get asyncResource(): EventEmitterReferencingAsyncResource;
|
---|
28 | static get EventEmitterAsyncResource(): typeof EventEmitterAsyncResource;
|
---|
29 | }
|
---|
30 | export = EventEmitterAsyncResource;
|
---|