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

listen

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

listen

Wait for the results of multiple callbacks

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
decreased by-22.62%
Maintainers
1
Weekly downloads
 
Created
Source

listen.js

Wait for the results of multiple callbacks.

Build Status

Install

npm install listen

Usage

var listen = require('listen');

var listener = listen();

var callbackA = listener();
var callbackB = listener();

/*
 * Do async stuff with callbacks.
 *
 * Callbacks follow the Node.js convention. They expect an error or null as
 * the first argument and an optional value as the second:
 *
 * Fail: callback(new Error('ouch!'));
 * Return: callback(null, 'some return value');
 */

listener.then(function (err, values) {
  /*
   * err    - 1) null if no callback err'd
   *          2) the error of the callback that err'd
   *          3) an error with name ErrorList wrapping multiple errors
   *
   * values - The non-undefined return values from all callbacks in order of
   *          callback creation
   */
});

API

  • listen() - creates a new listener.
  • listen(values) - creates a new listener with initial values. The given argument must be an array.
  • listener() - creates a new callback associated with the listener. Throws if called after then.
  • listener.then(func) - invokes the given function once all callbacks where invoked. Throws if already called.
  • listener.push(value) - pushes a value to the internal values array. Throws if called after then.
  • listener.err(error) - adds an error to the internal error list. Throws if called after then.

Run tests

make

Compile for browsers and minify

This requires nomo.js.

make compile

FAQs

Package last updated on 11 Jul 2012

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