Skip to content

Instantly share code, notes, and snippets.

@kevinold
Forked from joepie91/delay-promise.js
Created June 18, 2019 22:26
Show Gist options
  • Save kevinold/08283a8007c97c02d9cfb7cbe0c6a80a to your computer and use it in GitHub Desktop.
Save kevinold/08283a8007c97c02d9cfb7cbe0c6a80a 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