-
-
Save enishant/36bd3e3277373876bbdc875acba5e7d3 to your computer and use it in GitHub Desktop.
Fancy setTimeout wrapper using native Promise.
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
var wait = function(ms) { | |
ms = ms || 500; | |
return new Promise(function(resolve, reject){ | |
window.setTimeout(function() { | |
resolve(); | |
}, ms); | |
}); | |
}; | |
// USAGE | |
// --------- | |
wait(500).then(function() { | |
// Do stuff after 500ms | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment