npm

npm’s 2019 JavaScript ecosystem survey analysis is now available! Get your copy here »

batch-runner

0.7.0 • Public • Published

batch-runner

Build Status

A promise utility for batching.

Usage

const batchRunner = require('batch-runner');
const requests = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
const toPromise = (req, index) => Promise.resolve(req.toLowerCase());
 
batchRunner.run(requests, toPromise, {
  interval: 10, // default: 0
  concurrency: 3, // default: 1
  maxRetries: 2, // default: 0
  retryInterval: 100, // default: 0
  shouldRetry: err => true //default: err => true
}).then(results => {
  console.log(results);
}).catch(e => {
  console.log('Error:', e.message);
  console.log('Results:', e.results());
  console.log('Errors:', e.errors());
  console.log('Unprocessed:', e.unprocessedRequests());
  // see `e.items` for more information
});

LICENSE

MIT

Keywords

install

npm i batch-runner

Downloadsweekly downloads

6

version

0.7.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability