This is simply the ES6 version of https://gist.github.com/joepie91/2664c85a744e6bd0629c
import delayPromise from './delay-promise';
doThing()
.then(...)
.then(delayPromise(5000)) // Chain delayed by 5s
.then(...);
| const delayPromise = (duration) => (...args) => new Promise((resolve) => { | |
| setTimeout(() => { resolve(...args); }, duration); | |
| }); | |
| export default delayPromise; |
This is simply the ES6 version of https://gist.github.com/joepie91/2664c85a744e6bd0629c
import delayPromise from './delay-promise';
doThing()
.then(...)
.then(delayPromise(5000)) // Chain delayed by 5s
.then(...);