import { PushAdapter } from './common' ; type EventMap = GlobalEventHandlersEventMap ; /**
 * Convert DOM events to an async iterable iterator.
 */ const fromDom = < T extends keyof EventMap > ( init ) => ( type , target , options ? ) : AsyncIterableIterator < EventMap [ T ] > => { const adapter = init ( ) ; const listener = ( event ) => void adapter . push ( event ) ; target . addEventListener ( type , listener , options ) ; return adapter . wrap ( ( ) => target . removeEventListener ( type , listener , options ) ) ; } ; type Listener < T extends keyof EventMap > = ( e : EventMap [ T ] ) => void ; type Target < T extends keyof EventMap , L = Listener < T > , O = boolean | AddEventListenerOptions > = EventTarget & { addEventListener ( type , listener , options ? ) : void ; removeEventListener ( type , listener , options ? ) : void ; } ; export default fromDom ;