strict-event-emitter
Advanced tools
Comparing version 0.4.0 to 0.4.1
export declare type EventMap = { | ||
[eventName: string]: Array<unknown>; | ||
}; | ||
export declare type NewListenerEventListener<Events extends EventMap> = Listener<[ | ||
export declare type InternalEventNames = 'newListener' | 'removeListener'; | ||
export declare type InternalListener<Events extends EventMap> = Listener<[ | ||
eventName: keyof Events, | ||
listener: Listener<Array<unknown>> | ||
]>; | ||
export declare type RemoveListenerEventListener<Events extends EventMap> = Listener<[ | ||
eventName: keyof Events, | ||
listener: Listener<Array<unknown>> | ||
]>; | ||
export declare type Listener<Data extends Array<unknown>> = (...data: Data) => void; | ||
@@ -48,28 +45,23 @@ /** | ||
emit<EventName extends keyof Events>(eventName: EventName, ...data: Events[EventName]): boolean; | ||
addListener(eventName: InternalEventNames, listener: InternalListener<Events>): this; | ||
addListener<EventName extends keyof Events>(eventName: EventName, listener: Listener<Events[EventName]>): this; | ||
on(eventName: 'removeListener', listener: RemoveListenerEventListener<Events>): this; | ||
on(eventName: InternalEventNames, listener: InternalListener<Events>): this; | ||
on<EventName extends keyof Events>(eventName: EventName, listener: Listener<Events[EventName]>): this; | ||
once(eventName: 'newListener', listener: NewListenerEventListener<Events>): this; | ||
once(eventName: 'removeListener', listener: RemoveListenerEventListener<Events>): this; | ||
once(eventName: InternalEventNames, listener: InternalListener<Events>): this; | ||
once<EventName extends keyof Events>(eventName: EventName, listener: Listener<Events[EventName]>): this; | ||
prependListener(eventName: InternalEventNames, listener: InternalListener<Events>): this; | ||
prependListener<EventName extends keyof Events>(eventName: EventName, listener: Listener<Events[EventName]>): this; | ||
prependOnceListener(eventName: InternalEventNames, listener: InternalListener<Events>): this; | ||
prependOnceListener<EventName extends keyof Events>(eventName: EventName, listener: Listener<Events[EventName]>): this; | ||
removeListener(eventName: InternalEventNames, listener: InternalListener<Events>): this; | ||
removeListener<EventName extends keyof Events>(eventName: EventName, listener: Listener<Events[EventName]>): this; | ||
/** | ||
* Alias for `emitter.removeListener()`. | ||
* | ||
* @example | ||
* emitter.off('hello', listener) | ||
*/ | ||
off(eventName: InternalEventNames, listener: InternalListener<Events>): this; | ||
off<EventName extends keyof Events>(eventName: EventName, listener: Listener<Events[EventName]>): this; | ||
removeAllListeners(eventName?: InternalEventNames): this; | ||
removeAllListeners<EventName extends keyof Events>(eventName?: EventName): this; | ||
/** | ||
* Returns a copy of the array of listeners for the event named `eventName`. | ||
*/ | ||
listeners(eventName: InternalEventNames): Array<Listener<any>>; | ||
listeners<EventName extends keyof Events>(eventName: EventName): Array<Listener<Events[EventName]>>; | ||
/** | ||
* Returns the number of listeners listening to the event named `eventName`. | ||
*/ | ||
listenerCount(eventName: InternalEventNames): number; | ||
listenerCount<EventName extends keyof Events>(eventName: EventName): number; | ||
rawListeners<EventName extends keyof Events>(eventName: EventName): Array<Listener<Events[EventName]>>; | ||
} |
{ | ||
"name": "strict-event-emitter", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Type-safe implementation of EventEmitter for browser and Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14124
269