I first came up with this technique when working on my reimplementation of the coffee-script REPL to use the node REPL instead of the hacked together REPL that coffee-script came with.
It was required to provide multiline support for the coffee REPL. You can essentially replace an existing event listener with your own that then delegates to the original event listener. Handy when you need to patch existing behavior.
I first came up with this technique when working on my reimplementation of the coffee-script REPL to use the node REPL instead of the hacked together REPL that coffee-script came with.
https://github.com/jashkenas/coffee-script/blob/master/src/repl.coffee#L50-L59
It was required to provide multiline support for the coffee REPL. You can essentially replace an existing event listener with your own that then delegates to the original event listener. Handy when you need to patch existing behavior.