type Callback = () => Promise; type AsyncQueue = { push: (task: Callback) => Promise; flush: () => Promise; size: number; }; /** * Ensures that each callback pushed onto the queue is executed in series. * Such a quetie 😻 * @param opts.dedupeConcurrent If dedupeConcurrent is `true` it ensures that if multiple * tasks are pushed onto the queue while there is an active task, only the * last one will be executed, once the active task has completed. * e.g. in the below example, only 0 and 3 will be executed. * ``` * const queue = createAsyncQueue({ dedupeConcurrent: true }) * queue.push(async () => console.log(0)) // returns 0 * queue.push(async () => console.log(1)) // returns 3 * queue.push(async () => console.log(2)) // returns 3 * queue.push(async () => console.log(3)) // returns 3 * ``` * */ declare function createAsyncQueue(opts?: { dedupeConcurrent: boolean; }): AsyncQueue; declare const createAsyncQueues: (opts?: { dedupeConcurrent: boolean; }) => { push: (queueId: string, task: Callback) => Promise; flush: (queueId: string) => Promise; }; export { type AsyncQueue, createAsyncQueue, createAsyncQueues };