Created
December 21, 2018 15:11
-
-
Save David263/c1fbdb3f82964f048606665eac1ca349 to your computer and use it in GitHub Desktop.
A Promise version of setTimeout, to easily add a delay to an asynchronous operation
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
// Wrap setTimeout in a Promise | |
function delay(msec,value) | |
{ | |
return new Promise(function(OKFunction) | |
{ | |
setTimeout(OKFunction,msec,value); | |
}); | |
} // delay |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment