1 | declare module 'events' {
|
---|
2 | interface NodeEventTarget {
|
---|
3 | once(event: string | symbol, listener: (...args: any[]) => void): this;
|
---|
4 | }
|
---|
5 |
|
---|
6 | interface DOMEventTarget {
|
---|
7 | addEventListener(event: string, listener: (...args: any[]) => void, opts?: { once: boolean }): any;
|
---|
8 | }
|
---|
9 |
|
---|
10 | class EventEmitter extends NodeJS.EventEmitter {
|
---|
11 | constructor();
|
---|
12 |
|
---|
13 | static once(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>;
|
---|
14 | static once(emitter: DOMEventTarget, event: string): Promise<any[]>;
|
---|
15 | static on(emitter: NodeJS.EventEmitter, event: string): AsyncIterableIterator<any>;
|
---|
16 |
|
---|
17 | /** @deprecated since v4.0.0 */
|
---|
18 | static listenerCount(emitter: NodeJS.EventEmitter, event: string | symbol): number;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * This symbol shall be used to install a listener for only monitoring `'error'`
|
---|
22 | * events. Listeners installed using this symbol are called before the regular
|
---|
23 | * `'error'` listeners are called.
|
---|
24 | *
|
---|
25 | * Installing a listener using this symbol does not change the behavior once an
|
---|
26 | * `'error'` event is emitted, therefore the process will still crash if no
|
---|
27 | * regular `'error'` listener is installed.
|
---|
28 | */
|
---|
29 | static readonly errorMonitor: unique symbol;
|
---|
30 | static readonly captureRejectionSymbol: unique symbol;
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Sets or gets the default captureRejection value for all emitters.
|
---|
34 | */
|
---|
35 | // TODO: These should be described using static getter/setter pairs:
|
---|
36 | static captureRejections: boolean;
|
---|
37 | static defaultMaxListeners: number;
|
---|
38 | }
|
---|
39 |
|
---|
40 | import internal = require('events');
|
---|
41 | namespace EventEmitter {
|
---|
42 | // Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4
|
---|
43 | export { internal as EventEmitter };
|
---|
44 | }
|
---|
45 |
|
---|
46 | export = EventEmitter;
|
---|
47 | }
|
---|