Utility to flush the microtask queue (e.g., pending Promises) by returning a thenable that resolves when the queue is empty. Version 1.0.1 is stable, with no recent releases. It is a minimal, focused library extracted from React's enqueueTask implementation, ideal for testing or scenarios requiring deterministic microtask execution. Differentiates by providing a simple, dependency-free function without side effects.
npm install flush-microtasksNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates using flushMicroTasks to wait for pending microtasks (Promise callbacks) to complete before proceeding.
Call flushMicroTasks() again or use a loop if you need to drain continuously added microtasks.
Use named import: import { flushMicroTasks } from 'flush-microtasks'Use ES module import syntax.
Change to: import { flushMicroTasks } from 'flush-microtasks'Use import syntax or add "type": "module" to package.json.
No dependency data recorded yet.