Created
April 13, 2021 16:02
-
-
Save MatthewLymer/8233477ecad735c075a45d140ae25a75 to your computer and use it in GitHub Desktop.
async Yield and Delay implementations for JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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