Skip to content

Instantly share code, notes, and snippets.

@geta6
Last active December 16, 2015 19:39
Show Gist options
  • Save geta6/5486995 to your computer and use it in GitHub Desktop.
Save geta6/5486995 to your computer and use it in GitHub Desktop.
メソッド実行にHookさせます
# 例えば res.end なら
end = res.end
res.end = ->
res.end = end
res.emit 'end'
res.end.apply @, arguments
res.on 'end', ->
console.log 'triggered'
# 例えば console.log なら
log = console.log
console.log = ->
console.log = log
console.emit 'log'
console.log.apply @, arguments
console.on 'log', ->
util.print 'triggered\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment