New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

funq

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

funq

a simple asynchronous function queue

latest
Source
npmnpm
Version
4.0.3
Version published
Weekly downloads
10
66.67%
Maintainers
1
Weekly downloads
 
Created
Source

funq

Greenkeeper badge NPM version Build status License Code style

A simple asynchronous function queue, executing either sequentially or in parallel.

Installation

$ npm install funq --save

...or:

$ yarn add funq

Usage

Create a new instance of Funq(). Each object will have a push() method, taking a callback as an argument and sequential() and parallel() methods to kick the whole process off. The constructor function takes a completion callback with an error value which will either contain an error object/string, etc.. or be null if no errors were passed back, this is called once the whole chain of functions have finished.

If parallel() is used, then all functions pushed to the instance will run immediately and the completion callback will be called once the slowest function has finished, otherwise, using sequential() everything will run in order and take as long as all the functions take to complete. Also you can optionally pass a value back (i.e. done([value])) which will complete the sequence early.

Example:

const Funq = require('funq')

const queue = new Funq((err, value) => {
  if (err) return console.log(err) // an error was passed back and the sequence ended early
  // otherwise do stuff after sequence is fully completed
})

queue.push((fail, done) => {
  // do some async work and either fail with an error
  // or mark successfull with done

  // optionally pass a value back, this also has the effect
  // or completing the sequence early
  done({pass: 'value back'})
})

queue.push((fail, done) => {
  fail(new Error('an error occurred'))
})

queue.push((fail, done) => {
  // won't be called because error was passed back
})

queue.sequential() // or `.parallel()`

Browsers

Use browserify or similar.

Keywords

async

FAQs

Package last updated on 01 Apr 2017

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