Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

async-ear

bendrucker34MIT1.0.0

Manage and call async functions

listen, async, ear, function

readme

async-ear Build Status

Manage and call async functions

async-ear can register and manage a set of functions to call in parallel (default) or series with the same arguments.

Install

$ npm install --save async-ear

Usage

var Ear = require('async-ear')
// or Ear = require('async-ear/series')

var listeners = Ear()
listeners.add(function (a, callback) {
  //=> a === 1
  callback()
})
listeners(1, function done (err) {
  //=> err === null  
})

API

Listeners() -> function

Create a new listener group. Returns a listeners function that will call all listeners with the provided arguments. The listeners should provide a callback as its last argument which will be called with an error (or null).

listeners.add(listener) -> function

Adds a new listener. Returns a remove function that will remove the new listener when called. Each listener should expect a callback as its final argument.

listener

Required
Type: function Arguments: args..., callback

A listener to trigger when the parent function is called.

  • ear: synchronous version

License

MIT © Ben Drucker