🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

blocking-queue

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blocking-queue

Bloking FIFO queue and flow control using Promise.

0.0.1
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Blocking Queue

Bloking FIFO queue and flow control using Promise.

Installation

npm install blocking-queue

Example

var Queue = require('blocking-queue');
var QueueConsumer = require('blocking-queue').QueueConsumer;

var q = new Queue();
q.push('task1');
q.push('task2');
q.push('task3');
q.push('task4');
q.push('task5');

var c = new QueueConsumer(q);
c.start(function(task){
  return new Promise(function(resolve, reject){
    // working on task
    resolve();
  });
}, 2);

c.end().then(function(){
  // on all tasks done
});

API

new Queue()

Queue.push(task)

  • task {Object} required

Queue.pop()

  • return {Promise}

Queue.size()

  • return {integer}

new QueueConsumer(queue)

  • queue {Queue} required

QueueConsumer.start(consumer, [concurrency])

  • consumer {Function} required should be called with 1 parameters: task.
  • cocurrency {integer} optional, default: 1

QueueConsumer.end()

  • return {Promise}

License

MIT.

FAQs

Package last updated on 16 Aug 2015

Did you know?

Socket

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