Skip to content

Instantly share code, notes, and snippets.

@surma
Created February 23, 2021 16:39
Show Gist options
  • Save surma/1fde30101820faf494cc89d5feb1a972 to your computer and use it in GitHub Desktop.
Save surma/1fde30101820faf494cc89d5feb1a972 to your computer and use it in GitHub Desktop.
const task = cb => {
const mc = new MessageChannel();
mc.port1.postMessage(null);
mc.port2.addEventListener("message", () => {
cb();
}, {once: true});
mc.port2.start();
}
const microtask = cb => queueMicrotask(cb);
// Only available in node
// const nanotask = cb => process.nextTick(cb);
const synchronous = cb => cb();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment