UNPKG

tinycoll

Version:

A minimal reactive document store with Mongo-like querying, reactivity, TTL support, and optional persistence.

29 lines (28 loc) 649 B
export class PromiseQueue { #queue = []; #isRunning = false; push(fn) { this.#queue.push(fn); void this.#run(); } get size() { return this.#queue.length; } async #run() { if (this.#isRunning) return; this.#isRunning = true; while (this.#queue.length > 0) { const job = this.#queue.shift(); if (!job) continue; try { await job(); } catch (err) { console.error('PromiseQueue error:', err); } } this.#isRunning = false; } }