Created
July 6, 2014 02:31
-
-
Save npow/49d6a3f3a33d91c16b8f to your computer and use it in GitHub Desktop.
Promisified setTimeout()
This file contains hidden or 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 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