Skip to content

jinjor/batch-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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