Skip to content

Instantly share code, notes, and snippets.

@matadcze
Created March 20, 2023 17:36
Show Gist options
  • Save matadcze/53569aa274f25329893479c23a834303 to your computer and use it in GitHub Desktop.
Save matadcze/53569aa274f25329893479c23a834303 to your computer and use it in GitHub Desktop.
const sleep_st = (t) => new Promise((r) => setTimeout(r, t));
const sleep_im = () => new Promise((r) => setImmediate(r));
(async () => {
setImmediate(() => console.log(1));
console.log(2);
await sleep_st(0);
setImmediate(() => console.log(3));
console.log(4);
await sleep_im();
setImmediate(() => console.log(5));
console.log(6);
await 1;
setImmediate(() => console.log(7));
console.log(8);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment