Wondering what‚Äôs next for npm?Check out our public roadmap! ¬Ľ

    jobbel
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.1¬†‚Äʬ†Public¬†‚Äʬ†Published

    Jobbel - async job manager

    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;.

    Install

    npm i jobbel

    DownloadsWeekly Downloads

    2

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    8.16 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar