Projekt

Obecné

Profil

Stáhnout (1.8 KB) Statistiky
| Větev: | Revize:
1
declare module "events" {
2
    interface EventEmitterOptions {
3
        /**
4
         * Enables automatic capturing of promise rejection.
5
         */
6
        captureRejections?: boolean;
7
    }
8

    
9
    interface NodeEventTarget {
10
        once(event: string | symbol, listener: (...args: any[]) => void): this;
11
    }
12

    
13
    interface DOMEventTarget {
14
        addEventListener(event: string, listener: (...args: any[]) => void, opts?: { once: boolean }): any;
15
    }
16

    
17
    namespace EventEmitter {
18
        function once(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>;
19
        function once(emitter: DOMEventTarget, event: string): Promise<any[]>;
20
        function on(emitter: EventEmitter, event: string): AsyncIterableIterator<any>;
21
        const captureRejectionSymbol: unique symbol;
22

    
23
        /**
24
         * This symbol shall be used to install a listener for only monitoring `'error'`
25
         * events. Listeners installed using this symbol are called before the regular
26
         * `'error'` listeners are called.
27
         *
28
         * Installing a listener using this symbol does not change the behavior once an
29
         * `'error'` event is emitted, therefore the process will still crash if no
30
         * regular `'error'` listener is installed.
31
         */
32
        const errorMonitor: unique symbol;
33
        /**
34
         * Sets or gets the default captureRejection value for all emitters.
35
         */
36
        let captureRejections: boolean;
37

    
38
        interface EventEmitter extends NodeJS.EventEmitter {
39
        }
40

    
41
        class EventEmitter {
42
            constructor(options?: EventEmitterOptions);
43
            /** @deprecated since v4.0.0 */
44
            static listenerCount(emitter: EventEmitter, event: string | symbol): number;
45
            static defaultMaxListeners: number;
46
        }
47
    }
48

    
49
    export = EventEmitter;
50
}
(15-15/45)