Skip to content

Instantly share code, notes, and snippets.

@npow
Created July 6, 2014 02:31
Show Gist options
  • Save npow/49d6a3f3a33d91c16b8f to your computer and use it in GitHub Desktop.
Save npow/49d6a3f3a33d91c16b8f to your computer and use it in GitHub Desktop.
Promisified setTimeout()
function delay(ms) {
var deferred = Promise.pending();
setTimeout(function() {
deferred.fulfill();
}, ms);
return deferred.promise;
}
delay(1000).then(function () {
// do stuff
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment