import Queue from './Queue'; declare type Result = IteratorResult; /** * Async iterable iterator with a non-optional [[return]] method. */ interface BalancerAsyncIterableIterator extends AsyncIterableIterator { return(value?: A): Promise>; } /** * Balances a push queue with a pull queue. Pulling with an empty push * queue */ export default class Balancer implements AsyncIterableIterator { /** XXX */ readonly pushOverflow: Queue>; /** XXX */ readonly pullOverflow: Queue<(a: IteratorResult) => void>; /** XXX */ closed: boolean; /** * Pull a promise of the next [[IteratorResult]]. */ next(): Promise>; /** * Push the next value. * * @throws Throws if the balancer is closed */ push(value: A): void; /** * Returns itself, since it's already an iterator; */ [Symbol.asyncIterator](): this; /** * Closes the iterator; clears the queues and makes [[Balancer.next]] only * return [[closedResult]]. * * @param value The result value to be returned */ return(value?: A): Promise>; /** * Convert [[Balancer]] to a generic async iterable iterator to hide implementation details. * * @param onReturn Optional callback for when the iterator is closed with [[Balancer.return]] */ wrap(onReturn?: () => void): BalancerAsyncIterableIterator; } export {};