Socket
Socket
Sign inDemoInstall

queue-promise

Package Overview
Dependencies
0
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    queue-promise

A simple and small library for promise-based queues


Version published
Maintainers
1
Created

Readme

Source

queue-promise

Greenkeeper badge Build Status npm version npm downloads

A simple and small library for promise-based queues.

Installation

$ npm install queue-promise

Usage

import Queue from "queue-promise";

const q = new Queue( {
    concurrency : 1,
    interval    : 2000
} );

q.on( "resolve", data => console.log( data ) );
q.on( "reject", error => console.error( error ) );

q.add( asyncTaskA ); // resolved/rejected after 0s
q.add( asyncTaskB ); // resolved/rejected after 2s
q.add( asyncTaskC ); // resolved/rejected after 4s
q.add( asyncTaskD ); // resolved/rejected after 6s
q.start();

API

new Queue( options )

Create a new Queue instance with optionally injected options.

OptionDefaultDescription
concurrency5How many promises can be handled at the same time
interval500How often should new promises be handled (in ms)
public .add( promise )

Adds a promise to the queue.

public .start()

Starts the queue.

public .stop()

Stops the queue.

private .next()

Goes to the next request and stops the loop if there is no requests left.

public .on( event, callback )

Sets a callback for an event. You can set callback for those events: start, stop, tick, resolve, reject, end.

Keywords

FAQs

Last updated on 30 Aug 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