UNPKG

@benev/slate

Version:
19 lines 516 B
import { debounce } from "../../tools/debounce/debounce.js"; export class Scheduler { #queue = new Map(); #wait = Promise.resolve(); #actuate = debounce(0, () => { const functions = [...this.#queue.values()]; this.#queue.clear(); for (const fun of functions) fun(); }); get wait() { return this.#wait; } add(symbol, fun) { this.#queue.set(symbol, fun); this.#wait = this.#actuate(); } } //# sourceMappingURL=scheduler.js.map