event-emitters
Version:
19 lines (18 loc) • 751 B
TypeScript
import { EventSource } from './EventSource';
/**
* An async iterator implemented with an efficient queue.
*
* Make the async iterator also fulfil AsyncIterable, which is pretty pointless
* but needed to support certain APIs that are not implemented correctly.
*/
export declare class EventEmitterAsyncIterator<T> implements AsyncIterator<T>, AsyncIterable<T> {
private readonly eventSource;
private readonly emitted;
private readonly pendingListens;
constructor(eventSource: EventSource<T>);
private onEmit;
next(): Promise<IteratorResult<T, undefined>>;
return(): Promise<IteratorResult<T, undefined>>;
throw(error: Error): Promise<IteratorResult<T, undefined>>;
[Symbol.asyncIterator](): AsyncIterator<T>;
}