1.1.1 • Published 4 years ago

jobbel v1.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Jobbel - async job manager

npm.io Node version NPM Downloads Minified size License: MIT

Jobbel is a lightweight job manager that can handle a limited concurrent jobs.

Usage

The API of jobbel allows for three different parameters:

  • concurrent: number: the number of concurrent async jobs that can run simultaneously;
  • onResolve?: (result, status): a function that is triggered in resolving each job. The result of the job and the (new) status of jobbel are given as parameters;
  • onReject?: (result, status): a function that is triggered in rejecting each job. The result of the job and the (new) status of jobbel are given as parameters;
import jobbel from 'jobbel';

function resolve(result, state) { ... }
function reject(error, state) { ... }
const manager = jobbel({ concurrent: 3, onResolve: resolve, onReject: reject });

// .push requires (async) functions as input
manager.push(...myAsyncApiCallFunctions);

...

console.log(manager.status); // { pending: 0, resolved: x, rejected: y }

In the resolve and reject callback functions, the second parameter shows the current state of the job manager. It holds the following properties:

  • pending: the amount of jobs currently running. If this is 0 the job manager is finished;
  • resolved: the amount of jobs successfully finished;
  • rejected: the amount of jobs failed;.
1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago