Skip to content

Instantly share code, notes, and snippets.

@MatthewLymer
Created April 13, 2021 16:02
Show Gist options
  • Save MatthewLymer/8233477ecad735c075a45d140ae25a75 to your computer and use it in GitHub Desktop.
Save MatthewLymer/8233477ecad735c075a45d140ae25a75 to your computer and use it in GitHub Desktop.
async Yield and Delay implementations for JavaScript
function yield () {
return new Promise(resolve => setImmediate(() => resolve()));
}
function delay (milliseconds) {
return new Promise(resolve => setTimeout(() => resolve(), milliseconds));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment