Socket
Socket
Sign inDemoInstall

vow-queue

Package Overview
Dependencies
1
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vow-queue

Vow-based task queue


Version published
Weekly downloads
74K
decreased by-7.71%
Maintainers
1
Install size
75.5 kB
Created
Weekly downloads
 

Readme

Source

vow-queue NPM version Build Status

vow-queue is a module for task queue with weights and priorities

Installation

Module can be installed using npm:

npm install vow-queue

or bower:

bower install vow-queue

Usage

var Queue = require('vow-queue'),
    queue = new Queue({ weightLimit : 10 });
    
queue.enqueue(function() { // simple function
    return 2 * 2;
});

queue.enqueue(function() { // function returns a promise
    // do job
    return promise;
});

queue.enqueue( // task with custom priority and weight
    function() {
        // do job
    },
    {
        priority : 3, // this task will be started before the previous two
        weight   : 5
    });
    
queue.start(); // starts tasks processing

queue.enqueue(function() { }); // and enqueue yet another task

API

Creating queue

####new Queue([params])

  • params.weightLimit=100 limit of summary tasks weight which can be processed concurrently

Methods of queue

####Promise enqueue(taskFn, [taskParams]) Enqueue given task in queue

  • taskFn task function which can return either a promise or a value
  • taskParams.weight=1 weight of given task
  • taskParams.priority=1 priority of given task

Returns promise which will be resolved when given task is done

####void start() Starts processing of tasks in queue

####void stop() Stops processing of tasks in queue

####Boolean isStarted() Returns whether processing is started

####void setParams(params) Sets queue params

  • params.weightLimit=100 limit of summary tasks weight which can be processed concurrently

####Object getStats() Returns statistics about queue

FAQs

Last updated on 04 Oct 2017

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