Last active
December 21, 2015 20:00
-
-
Save madbook/6358595 to your computer and use it in GitHub Desktop.
replace `obj` with a module object. This wraps every method of that object that dumps nested, collapsible console logs any time those methods are called. logs include arguments, return value, and execution time.
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
for (i in obj) | |
if (typeof obj[i] === 'function' && i !== 'toString') | |
(function (method) { | |
var fnc = obj[method] | |
obj[method] = function () { | |
var x | |
console.groupCollapsed(this + " -> " + method) | |
console.dir(this) | |
console.dir(arguments) | |
console.time(method + ' time') | |
console.log(x = fnc.apply(this, arguments)) | |
console.timeEnd(method + ' time') | |
console.groupEnd() | |
return x | |
} | |
})(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
toString
method