import type { AbortBehavior, EventHandlerMap, EventTarget } from './types.ts'; /** * Listens for the next `event` on the `target` object. Instead of providing a callback * function to run when the event is emitted, this function returns a `Promise` * that resolves when the next matching event is triggered. * * @param target The target to add the event handler to. * @param event The name of the event you are targeting. * * @returns A `Promise` that resolves when the next matching event is triggered. * The promise resolves with the value of the first argument passed to the event. * If you pass the `signal` option, the promise may also resolve with `undefined` * (in case the signal is aborted before the event is emitted). If you also set * the `abort` option to `'reject'`, the promise will instead reject with an * `AbortError` when the signal is aborted. * * @example * const button = document.querySelector('button'); * * const nextClickEvent = await once(button, 'click'); * console.log('clicked!', nextClickEvent); */ export declare function once, Event extends keyof Events = keyof Events>(target: EventTarget, event: Event, options: { /** * An `AbortSignal` to cancel listening to the event. */ signal: AbortSignal; /** * How to handle the `AbortSignal` being aborted. When set to `'reject'`, * the promise will instead reject with an `AbortError` in this case. */ abort: 'reject'; }): Promise; export declare function once, Event extends keyof Events = keyof Events>(target: EventTarget, event: Event, options?: { /** * An `AbortSignal` to cancel listening to the event. */ signal?: AbortSignal; /** * How to handle the `AbortSignal` being aborted. Defaults to `'resolve'`, * which causes the promise to resolve with `undefined` if the signal is * aborted before the next matching event. If set to `'reject'`, the promise * will instead reject with an `AbortError` in this case. */ abort?: AbortBehavior; }): Promise; export declare function once, Event extends keyof Events = keyof Events>(target: EventTarget, event: Event, options?: { /** * An `AbortSignal` to cancel listening to the event. */ signal?: never; /** * How to handle the `AbortSignal` being aborted. Defaults to `'resolve'`, * which causes the promise to resolve with `undefined` if the signal is * aborted before the next matching event. If set to `'reject'`, the promise * will instead reject with an `AbortError` in this case. */ abort?: AbortBehavior; }): Promise; //# sourceMappingURL=once.d.ts.map