Skip to content

Instantly share code, notes, and snippets.

@thelebster
Forked from joepie91/delay-promise.js
Created June 26, 2018 01:38
Show Gist options
  • Select an option

  • Save thelebster/0224abbf8cbeda02be52112d2d57ed84 to your computer and use it in GitHub Desktop.

Select an option

Save thelebster/0224abbf8cbeda02be52112d2d57ed84 to your computer and use it in GitHub Desktop.
ES6 Promise.delay
module.exports = function(duration) {
return function(){
return new Promise(function(resolve, reject){
setTimeout(function(){
resolve();
}, duration)
});
};
};
// Usage:
var delayPromise = require("./delay-promise");
doThing()
.then(...)
.then(delayPromise(5000))
.then(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment