mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
f1a6b8d66d
* chore: vendor Mitt into src/common/third-party As discussed in #6203 we need to vendor our common dependencies in so that when we ship an ESM build all imports point to file paths and do not rely on Node resolution (e.g. a browser does not understand `import mitt from 'mitt'`).
20 lines
907 B
TypeScript
20 lines
907 B
TypeScript
export declare type EventType = string | symbol;
|
|
export declare type Handler = (event?: any) => void;
|
|
export declare type WildcardHandler = (type: EventType, event?: any) => void;
|
|
export declare type EventHandlerList = Array<Handler>;
|
|
export declare type WildCardEventHandlerList = Array<WildcardHandler>;
|
|
export declare type EventHandlerMap = Map<EventType, EventHandlerList | WildCardEventHandlerList>;
|
|
export interface Emitter {
|
|
on(type: EventType, handler: Handler): void;
|
|
on(type: '*', handler: WildcardHandler): void;
|
|
off(type: EventType, handler: Handler): void;
|
|
off(type: '*', handler: WildcardHandler): void;
|
|
emit<T = any>(type: EventType, event?: T): void;
|
|
emit(type: '*', event?: any): void;
|
|
}
|
|
/** Mitt: Tiny (~200b) functional event emitter / pubsub.
|
|
* @name mitt
|
|
* @returns {Mitt}
|
|
*/
|
|
export default function mitt(all?: EventHandlerMap): Emitter;
|