�PNG  IHDR��;���IDATx��ܻn�0���K�� �)(�pA��� ���7�LeG{�� �§㻢|��ذaÆ 6lذaÆ 6lذaÆ 6lom��$^�y���ذag�5bÆ 6lذaÆ 6lذa{���� 6lذaÆ �`����}H�Fkm�,�m����Ӫ���ô�ô!� �x�|'ܢ˟;�E:���9�&ᶒ�}�{�v]�n&�6� �h��_��t�ڠ͵-ҫ���Z;��Z$�.�P���k�ž)�!��o���>}l�eQfJ�T��u і���چ��\��X=8��Rن4`Vw�l�>����n�G�^��i�s��"ms�$�u��i��?w�bs[m�6�K4���O���.�4��%����/����b�C%��t ��M�ז� �-l�G6�mrz2���s�%�9��s@���-�k�9�=���)������k�B5����\��+͂�Zsٲ ��Rn��~G���R���C����� �wIcI��n7jJ���hۛNCS|���j0��8y�iHKֶۛ�k�Ɉ+;Sz������L/��F�*\��Ԕ�#"5��m�2��[S��������=�g��n�a�P�e�ғ�L�� lذaÆ 6l�^k��̱aÆ 6lذaÆ 6lذa;���� �_��ذaÆ 6lذaÆ 6lذaÆ ���R���IEND�B` /// declare class TimeoutErrorClass extends Error { readonly name: 'TimeoutError'; constructor(message?: string); } declare namespace pEvent { type TimeoutError = TimeoutErrorClass; type AddRemoveListener = ( event: EventName, listener: (...arguments: Arguments) => void ) => void; interface Emitter { on?: AddRemoveListener; addListener?: AddRemoveListener; addEventListener?: AddRemoveListener; off?: AddRemoveListener; removeListener?: AddRemoveListener; removeEventListener?: AddRemoveListener; } type FilterFunction = ( ...arguments: ElementType ) => boolean; interface CancelablePromise extends Promise { cancel(): void; } interface Options { /** Events that will reject the promise. @default ['error'] */ readonly rejectionEvents?: ReadonlyArray; /** By default, the promisified function will only return the first argument from the event callback, which works fine for most APIs. This option can be useful for APIs that return multiple arguments in the callback. Turning this on will make it return an array of all arguments from the callback, instead of just the first argument. This also applies to rejections. @default false @example ``` import pEvent = require('p-event'); import emitter from './some-event-emitter'; (async () => { const [foo, bar] = await pEvent(emitter, 'finish', {multiArgs: true}); })(); ``` */ readonly multiArgs?: boolean; /** Time in milliseconds before timing out. @default Infinity */ readonly timeout?: number; /** Filter function for accepting an event. @example ``` import pEvent = require('p-event'); import emitter from './some-event-emitter'; (async () => { const result = await pEvent(emitter, '🦄', value => value > 3); // Do something with first 🦄 event with a value greater than 3 })(); ``` */ readonly filter?: FilterFunction; } interface MultiArgumentsOptions extends Options { readonly multiArgs: true; } interface MultipleOptions extends Options { /** The number of times the event needs to be emitted before the promise resolves. */ readonly count: number; /** Whether to resolve the promise immediately. Emitting one of the `rejectionEvents` won't throw an error. __Note__: The returned array will be mutated when an event is emitted. @example ``` import pEvent = require('p-event'); const emitter = new EventEmitter(); const promise = pEvent.multiple(emitter, 'hello', { resolveImmediately: true, count: Infinity }); const result = await promise; console.log(result); //=> [] emitter.emit('hello', 'Jack'); console.log(result); //=> ['Jack'] emitter.emit('hello', 'Mark'); console.log(result); //=> ['Jack', 'Mark'] // Stops listening emitter.emit('error', new Error('😿')); emitter.emit('hello', 'John'); console.log(result); //=> ['Jack', 'Mark'] ``` */ readonly resolveImmediately?: boolean; } interface MultipleMultiArgumentsOptions extends MultipleOptions { readonly multiArgs: true; } interface IteratorOptions extends Options { /** Maximum number of events for the iterator before it ends. When the limit is reached, the iterator will be marked as `done`. This option is useful to paginate events, for example, fetching 10 events per page. @default Infinity */ limit?: number; /** Events that will end the iterator. @default [] */ resolutionEvents?: ReadonlyArray; } interface IteratorMultiArgumentsOptions extends IteratorOptions { multiArgs: true; } } declare const pEvent: { /** Promisify an event by waiting for it to be emitted. @param emitter - Event emitter object. Should have either a `.on()`/`.addListener()`/`.addEventListener()` and `.off()`/`.removeListener()`/`.removeEventListener()` method, like the [Node.js `EventEmitter`](https://nodejs.org/api/events.html) and [DOM events](https://developer.mozilla.org/en-US/docs/Web/Events). @param event - Name of the event or events to listen to. If the same event is defined both here and in `rejectionEvents`, this one takes priority.*Note**: `event` is a string for a single event type, for example, `'data'`. To listen on multiple events, pass an array of strings, such as `['started', 'stopped']`. @returns Fulfills when emitter emits an event matching `event`, or rejects if emitter emits any of the events defined in the `rejectionEvents` option. The returned promise has a `.cancel()` method, which when called, removes the event listeners and causes the promise to never be settled. @example ``` // In Node.js: import pEvent = require('p-event'); import emitter from './some-event-emitter'; (async () => { try { const result = await pEvent(emitter, 'finish'); // `emitter` emitted a `finish` event console.log(result); } catch (error) { // `emitter` emitted an `error` event console.error(error); } })(); // In the browser: (async () => { await pEvent(document, 'DOMContentLoaded'); console.log('😎'); })(); ``` */ ( emitter: pEvent.Emitter, event: string | symbol | ReadonlyArray, options: pEvent.MultiArgumentsOptions ): pEvent.CancelablePromise; ( emitter: pEvent.Emitter, event: string | symbol | ReadonlyArray, filter: pEvent.FilterFunction<[EmittedType]> ): pEvent.CancelablePromise; ( emitter: pEvent.Emitter, event: string | symbol | ReadonlyArray, options?: pEvent.Options<[EmittedType]> ): pEvent.CancelablePromise; /** Wait for multiple event emissions. Returns an array. */ multiple( emitter: pEvent.Emitter, event: string | symbol | ReadonlyArray, options: pEvent.MultipleMultiArgumentsOptions ): pEvent.CancelablePromise; multiple( emitter: pEvent.Emitter, event: string | symbol | ReadonlyArray, options: pEvent.MultipleOptions<[EmittedType]> ): pEvent.CancelablePromise; /** @returns An [async iterator](https://2ality.com/2016/10/asynchronous-iteration.html) that lets you asynchronously iterate over events of `event` emitted from `emitter`. The iterator ends when `emitter` emits an event matching any of the events defined in `resolutionEvents`, or rejects if `emitter` emits any of the events defined in the `rejectionEvents` option. @example ``` import pEvent = require('p-event'); import emitter from './some-event-emitter'; (async () => { const asyncIterator = pEvent.iterator(emitter, 'data', { resolutionEvents: ['finish'] }); for await (const event of asyncIterator) { console.log(event); } })(); ``` */ iterator( emitter: pEvent.Emitter, event: string | symbol | ReadonlyArray, options: pEvent.IteratorMultiArgumentsOptions ): AsyncIterableIterator; iterator( emitter: pEvent.Emitter, event: string | symbol | ReadonlyArray, filter: pEvent.FilterFunction<[EmittedType]> ): AsyncIterableIterator; iterator( emitter: pEvent.Emitter, event: string | symbol | ReadonlyArray, options?: pEvent.IteratorOptions<[EmittedType]> ): AsyncIterableIterator; // TODO: Remove this for the next major release default: typeof pEvent; TimeoutError: typeof TimeoutErrorClass; }; export = pEvent;