Socket
Book a DemoInstallSign in
Socket

either

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

either

one either one or the other event do something once

latest
Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
3
-78.57%
Maintainers
1
Weekly downloads
 
Created
Source

node-either

Build Status](http://travis-ci.org/brianc/node-either)

Handle either one event or another one exactly once.

api

var either = require('either');

either(eventEmitter, fooEventName, fooListener, barEventName, barListener)

eventEmitter : object - an instance of EventEmitter fooEventName : string - the name of the first event fooListener : function - the listener to call if the first event fires first barEventName : string - the name of the second event barListener : function - the listener to call if the second event fires

All arguments are required.

example

var either = require('either');
var net = require('net');

var connect = function(address, callback) {
  var socket = net.connect(address);
  either(socket,
         'connect', function() {
           socket.setEncoding('utf8');
           callback(null, socket);
         },
         'error', callback);
}

license

MIT

FAQs

Package last updated on 06 Mar 2013

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