forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventemitter3.d.ts
102 lines (92 loc) · 3.21 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Type definitions for EventEmitter3 0.1.6
// Project: https://github.com/primus/eventemitter3
// Definitions by: Yuichi Murata <https://github.com/mrk21>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module EventEmitter3 {
// __Base is hack for https://github.com/Microsoft/TypeScript/issues/3602
class __Base {
/**
* Minimal EventEmitter interface that is molded against the Node.js
* EventEmitter interface.
*
* @constructor
* @api public
*/
constructor();
/**
* Return a list of assigned event listeners.
*
* @param {String} event The events that should be listed.
* @returns {Array}
* @api public
*/
listeners(event: string): Function[];
/**
* Emit an event to all registered event listeners.
*
* @param {String} event The name of the event.
* @returns {Boolean} Indication if we've emitted an event.
* @api public
*/
emit(event: string, ...args: any[]): boolean;
/**
* Register a new EventListener for the given event.
*
* @param {String} event Name of the event.
* @param {Functon} fn Callback function.
* @param {Mixed} context The context of the function.
* @api public
*/
on(event: string, fn: Function, context?: any): EventEmitter;
/**
* Add an EventListener that's only called once.
*
* @param {String} event Name of the event.
* @param {Function} fn Callback function.
* @param {Mixed} context The context of the function.
* @api public
*/
once(event: string, fn: Function, context?: any): EventEmitter;
/**
* Remove event listeners.
*
* @param {String} event The event we want to remove.
* @param {Function} fn The listener that we need to find.
* @param {Boolean} once Only remove once listeners.
* @api public
*/
removeListener(event: string, fn: Function, once?: boolean): EventEmitter;
/**
* Remove all listeners or only the listeners for the specified event.
*
* @param {String} event The event want to remove all listeners for.
* @api public
*/
removeAllListeners(event: string): EventEmitter;
//
// Alias methods names because people roll like that.
//
off(event: string, fn: Function, once?: boolean): EventEmitter;
addListener(event: string, fn: Function, context?: any): EventEmitter;
//
// This function doesn't apply anymore.
//
setMaxListeners(): EventEmitter;
}
export class EventEmitter extends __Base { }
export module EventEmitter {
//
// Expose the module.
//
export class EventEmitter extends __Base {}
export class EventEmitter2 extends __Base {}
export class EventEmitter3 extends __Base {}
}
}
declare module 'eventemitter3' {
//
// Expose the module.
//
class EventEmitter extends EventEmitter3.EventEmitter {}
export = EventEmitter;
}