batch-jobs

1.0.2 • Public • Published

batch-jobs

Installation

$ npm install batch-jobs

API

const BatchJobs = require('batch-jobs')
const batchJobs = new BatchJobs(10)
 
// Set the concurrency in the constructor or with the following function:
batchJobs.setConcurrency(20)
 
batchJobs.on('progress', console.log)
batchJobs.on('end', console.log)
 
batchJobs.push(done => fetchData(1, done))
batchJobs.push(done => fetchData(2, done))
 
batchJobs.start()
 
function fetchData(amount, done) {
  setTimeout(() => {
    done(new Array(amount).fill(amount))
  }, 500)
}

Events

Progress

{
  total: 2,
  running: 1,
  pending: 0,
  data: [ [1] ]
}

End

[ [1], [2, 2] ]

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i batch-jobs

    Weekly Downloads

    6

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • filoozom