1.0.0 • Published 7 years ago
promise-serial-exec v1.0.0
promise-serial-exec
Execute promises sequentially, aka sequential Promise.all
.
Can be useful for CPU-intensive operations, databases, scrapping...
Usage
const serialExec = require('promise-serial-exec')
const urls = [
url1,
url2,
url3
];
// make the promise callables so they're executed on-demand
const promiseCalls = urls.map((url, i) => () => fetch(url))
// urls will be fetched in order
serialExec(promiseCalls).then(console.log)
// will add a 0-500ms delay between each call
serialExec(promiseCalls, {
randomTimeout: 500
}).then(console.log)
1.0.0
7 years ago