import type { DebouncedFunc } from 'lodash'; import { Emitter } from './event-emitter'; declare type MaybePromise = T | Promise; export interface QueueOptions { flushInterval?: number; onSend?: (items: T[]) => MaybePromise; } export declare class Queue extends Emitter { readonly flushed: T[]; readonly queue: Set; readonly scheduleSend: DebouncedFunc<() => void>; private flushing; constructor(options?: QueueOptions); add(item: T): void; flush(): void; get all(): T[]; reset(): void; protected onSend(_items: T[]): MaybePromise; /** * Simplistic promise queue * Attempt to deliver all items in the queue, and then clear it. * If `this.onSend` returns false, the queue will not be cleared. * If `this.onSend` throws, the queue will not be cleared. * If we are already flushing, we'll delay the attempt by scheduling another flush. */ send(force?: boolean): void; } export {};