Created
September 20, 2012 21:25
-
-
Save dyoder/3758442 to your computer and use it in GitHub Desktop.
Event wrapper
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
_emit = EventEmitter.prototype.emit | |
EventEmitter.prototype.emit = -> | |
console.log arguments[0] | |
_emit(arguments) |
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
_emit = myStream.emit | |
myStream.emit = -> | |
# ... |
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
trace = (thing,label="Emit") -> | |
unless thing.emit?.apply? | |
throw "trace called on object with no 'emit' function: #{thing}" | |
emit = thing.emit | |
thing.emit = -> | |
console.log("#{label}: #{arguments[0]}") | |
emit(arguments) | |
thing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment