const LIMIT = 25000; let taskCounter = 0; export function queueTask(f: () => void) { taskCounter++; if (taskCounter === LIMIT) { setTimeout(() => taskCounter = 0, 0); } if (taskCounter >= LIMIT) { setTimeout(f, 0); } else { queueMicrotask(f); } }