Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-promise-queue

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-promise-queue

wrapper around async.queue to make some common usages simpler

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
147K
increased by0.62%
Maintainers
1
Weekly downloads
 
Created
Source

async-promise-queue

Build Status

A wrapper around the async module, that provides an improved promise queue.

Some highlights:

  • promiseified method (all wired up)
  • in a failure scenario, it will wait for pending work before rejecting. This prevents the run-away work problem.

Usage

npm install async-promise-queue

or

yarn add async-promise-queue

Debug logging

DEBUG="async-promise-queue*" node <your program>

And you will be informed when a queue is used, and what its concurrency becomes (note: we can always add more logging, submit your ideas as pull requests!)

Example

'use strict';

const queue = require('async-promise-queue');

queue.async // a reference to the `async` module which `async-promise-queue` is requiring.

// the example worker
const worker = queue.async.asyncify(function(work) {
  console.log('work', work.file);
  return new Promise(resolve => {
    if (work.file === '/path-2') { throw new Error('/path-2'); }
    if (work.file === '/path-3') { throw new Error('/path-3'); }
    setTimeout(resolve, work.duration);
  });
});

// the work
const work = [
  { file:'/path-1',  duration: 1000 },
  { file:'/path-2',  duration: 50 },
  { file:'/path-3',  duration: 100 },
  { file:'/path-4',  duration: 50 },
];

// calling our queue helper
queue(worker, work, 3)
  .catch(reason => console.error(reason))
  .then(value   => console.log('complete!!', value))

FAQs

Package last updated on 10 May 2019

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc