Created
December 23, 2010 17:24
-
-
Save joshthecoder/753275 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stream.mapEvents | |
connect: -> | |
data: (data) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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