UNPKG

mgraph.events

Version:

Modern eventing library for Node.js and browsers

16 lines (13 loc) 476 B
// index.d.ts export type EventKey = string | number | symbol; export type EventCallback = (...args: any[]) => void; export interface EventedType { on(eventName: EventKey, callback: EventCallback, ctx?: any): this; off(eventName?: EventKey, callback?: EventCallback): this; fire(eventName: EventKey, ...args: any[]): this; } export default function eventify<T extends {}>(subject: T & { on?: never; off?: never; fire?: never; }): EventedType & T;