-
Notifications
You must be signed in to change notification settings - Fork 2
/
eventemitter3.d.ts
50 lines (48 loc) · 1.36 KB
/
eventemitter3.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
declare module 'eventemitter3' {
namespace EventEmitter3 {
type Listener<Data = any> = (...args: Data[]) => void;
interface Event<Data = any> {
fn: Listener<Data>;
context: any;
once: boolean;
}
}
class EventEmitter3<Names extends string = string, Data = any> {
static prefixed: string | boolean;
_events: { [name: string]: EventEmitter3.Event<Data> | EventEmitter3.Event<Data>[] };
_eventsCount: number;
eventNames<Name extends Names>(): Name[];
listeners<Name extends Names>(name: Name): EventEmitter3.Listener<Data>[];
listenerCount<Name extends Names>(name: Name): number;
emit<Name extends Names>(name: Name, ...args: Data[]): void;
on<Name extends Names>(
name: Name,
listener: EventEmitter3.Listener<Data>,
context?: any,
): this;
addListener<Name extends Names>(
name: Name,
listener: EventEmitter3.Listener<Data>,
context?: any,
): this;
once<Name extends Names>(
name: Name,
listener: EventEmitter3.Listener<Data>,
context?: any,
): this;
removeListener<Name extends Names>(
name: Name,
listener?: EventEmitter3.Listener<Data>,
context?: any,
once?: boolean,
): this;
off<Name extends Names>(
name: Name,
listener?: EventEmitter3.Listener<Data>,
context?: any,
once?: boolean,
): this;
removeAllListeners<Name extends Names>(name?: Name): this;
}
export = EventEmitter3;
}