function
jsc.drainMicrotasks
Runs every pending microtask right now: promise reactions, queueMicrotask() callbacks, and process.nextTick() callbacks. The event loop does not run: the callbacks of completed I/O, messages, and timers wait until the current callback returns.
Microtasks normally run only after the current script or callback finishes; this lets synchronous code observe their effects immediately.
import { drainMicrotasks } from "bun:jsc";
let resolved = false;
Promise.resolve().then(() => {
resolved = true;
});
drainMicrotasks();
resolved; // true