Skip to content

Instantly share code, notes, and snippets.

@joshthecoder
Created December 23, 2010 17:24
Show Gist options
  • Save joshthecoder/753275 to your computer and use it in GitHub Desktop.
Save joshthecoder/753275 to your computer and use it in GitHub Desktop.
/*
* event-emitter-plus.js
*
* An extended EventEmitter with the following new additions:
* + mapEvents(events) - Add the following listeners to the event specified by their key.
*/
events = require("events");
events.EventEmitter.prototype.mapEvents = function (events) {
for (var eventName in events) {
this.on(eventName, events[eventName]);
}
}
exports.EventEmitter = events.EventEmitter;
stream.mapEvents
connect: ->
data: (data) ->
stream.mapEvents({
connect: function () { },
data: function (data) { }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment