Last active
August 29, 2015 14:06
-
-
Save rohozhnikoff/54e79dcbfc327daf54c3 to your computer and use it in GitHub Desktop.
observe all methods calls
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
# hard to perfomance | |
className = getClassName(@) | |
newProto = {} | |
_(@__proto__).each((value, name) => | |
newProto[name] = do => | |
if typeof value is 'function' | |
return => | |
consoleMe = ['>>', [className, name].join('.')] | |
consoleMe.push '| call with', arguments if arguments.length > 0 | |
console.log.apply console, consoleMe | |
return value.apply(@, arguments) | |
else | |
return value | |
).value() | |
_(@__proto__).extend(newHash) | |
# move to external | |
getClassName = (instance) -> | |
funcNameRegex = /function (.{1,})\(/ | |
results = (funcNameRegex).exec((instance).constructor.toString()) | |
if(results && results.length > 1) then results[1] else "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment