1.0.2 • Published 6 years ago

batch-jobs v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

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] ]
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago