either

one either one or the other event do something once

node-either

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

Handle either one event or another one exactly once.

var either = require('either');

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.

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

MIT