Socket
Socket
Sign inDemoInstall

async-fun-queue

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    async-fun-queue

a simple queue executing async functions linearly with pause/resume


Version published
Maintainers
1
Created

Readme

Source

async-fun-queue

Build Status Images

A simple queue executing async functions linearly with pause/resume

Installation

npm install async-fun-queue

Example

The most common use case:

var queue = new AsyncQueue([1, 2, 3], function (job, done) {
    collection.push(job);
    // simulate async
    setTimeout(function () {
        done();
    }, 100);
});
queue.on('jobStart', function (job) {
    // job begin to run
});
queue.on('jobDone', function (job) {
    // job is done
});
queue.on('end', function () {
    // all jobs are done
});

queue.run();

A more complicated use case, with pause and resume method to controll the execution process:

var queue = new AsyncQueue([1, 2, 3], function (job, done) {
    setTimeout(function () {
        done();
        if (job === 2) {
            queue.pause();
            setTimeout(function () {
                queue.resume();
            }, 100);
        }
    }, 100);
});
queue.on('pause', function () {
    // queue is paused
});
queue.on('resume', function () {
    // queue is resumed
});

queue.run();

Keywords

FAQs

Last updated on 06 Oct 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc