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

@jjmschofield/await-queue

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jjmschofield/await-queue

A charming little queue filled with awaitable tasks

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

await-queue

CircleCI Coverage Status Known Vulnerabilities

A simple awaited queue for NodeJs.

Designed to make managing concurrency limiting a breeze using tidy async/await syntax.

Installation

$ npm install @jjmschofield/await-queue

Usage

// Import the module
const { Queue } = require('@jjmschofield/await-queue');

const someQueableThing = async () =>{
    // Create a queue
    const queue = new Queue();
    
    // Await your task
    const result = await queue.add(someAsyncTask, { prop: 'value' });
    
    // Profit
}

Your async task can be any awaitable thing, it should take an object of inputs as it's first parameter eg:

const someAsyncTask = async ({ a, b }) =>{
    return { a, b };
}

As you can imagine, you can add virtually any function in which returns a promise, the world is your oyster!

Config

What is a handy library without some config options? Here are yours:

const { Queue, QUEUE_MODE } = require('<path to file>');

const queue = new Queue({ 
    maxRetry: 3, // Number of times to retry a thing before returning the final error recieved
    mode: QUEUE_MODE.FIFO, // Can be 'FIFO' or 'LIFO'
    concurrency: 1, // How many tasks do you want to run at once?
}); 

Keywords

FAQs

Package last updated on 11 Jun 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