-
Notifications
You must be signed in to change notification settings - Fork 8
/
emitter.d.ts
40 lines (36 loc) · 1.81 KB
/
emitter.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
import type events from 'events';
type BaseEventEmitter = Omit<events.EventEmitter, 'emit'|'once'|'on'|'off'|'prependOnceListener'|'prependListener'|'addListener'|'removeListener'|'removeAllListeners'>;
interface EventEmitter extends BaseEventEmitter {}
declare type TEventType = string | symbol;
declare type TListener = (...args: any[]) => Promise<any>;
declare type TFilter<T = any> = {
<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[];
(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[];
}
declare class EventEmitter implements EventEmitter {
private _resultFilter;
private _events;
private _eventsCount;
private _domain;
get maxListeners(): number;
set maxListeners(n: number);
getResultFilter(): TFilter | undefined;
setResultFilter(filter: TFilter | undefined): this;
get resultFilter(): TFilter | undefined;
set resultFilter(filter: TFilter | undefined);
emit(type: TEventType, ...args: any[]): Promise<any>;
addListener(type: TEventType, listener: TListener): Promise<any>;
prependListener(type: TEventType, listener: TListener): Promise<any>;
once(type: TEventType, listener?: TListener): Promise<any>;
prependOnceListener(type: TEventType, listener: TListener): Promise<any>;
removeLij
stener(type: TEventType, listener: TListener): Promise<any>;
removeAllListeners(type?: string | symbol): Promise<any>;
on(type: TEventType, listener: TListener): Promise<any>;
off(type: TEventType, listener: TListener): Promise<any>;
static EventEmitter: typeof EventEmitter;
static defaultMaxListeners: number | undefined;
static usingDomains: boolean | undefined;
static listenerCount: (events: EventEmitter, type: TEventType) => number;
}
export = EventEmitter;