promise-serial-exec

1.0.0 • Public • Published

promise-serial-exec

npm license github-issues Circle CI build status

nodei.co

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)

Package Sidebar

Install

npm i promise-serial-exec

Weekly Downloads

41

Version

1.0.0

License

MIT

Unpacked Size

6.53 kB

Total Files

8

Last publish

Collaborators

  • revolunet