type EventType = ( ... args : Array < any > ) => void ; type EventsTableType = { [ key ] : Array < EventType > ; } ; type SubscriberType = ( entry : any ) => void ; async function emitter ( events , eventName , args ? , subscribers ? ) { const isEventWildcard = ( eventName === '*' ) ; const argsPass = ( args !== undefined ) ? args : [ ] ; for ( const eventKey of Object . keys ( events ) ) { if ( ! isEventWildcard && eventName !== eventKey ) { continue ; } for ( const eventSubscriber of events [ eventKey ] ) { if ( subscribers !== undefined ) { subscribers . forEach ( ( subscriber ) => { subscriber ( { event : eventKey , subscriber : eventSubscriber . name , args : args } ) ; } ) ; } await eventSubscriber ( ... argsPass ) ; } } } export { emitter as default , } ;