Skip to content

Instantly share code, notes, and snippets.

@joepie91
Last active September 19, 2016 19:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joepie91/583db45f3a30552a7cd2 to your computer and use it in GitHub Desktop.
Save joepie91/583db45f3a30552a7cd2 to your computer and use it in GitHub Desktop.
Bluebird Promise.delay for ES6 Promises
var Promise = require("es6-promise").Promise;
module.exports = function(delay){
return function(value) {
return new Promise(function(resolve, reject){
setTimeout(function(){
resolve(value);
}, delay)
});
}
}
var delay = require("./delay");
// ...
.then(function(value){
return doAnotherThing();
})
.then(delay(5000))
.then(function(value){
return doThingAfterFiveSeconds(value);
})
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment