Created
October 29, 2022 10:20
-
-
Save MikeRatcliffe/c4188f1726cb2115f2bd06bf69b1c23d to your computer and use it in GitHub Desktop.
Function Tracing
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
const _apply = Function.prototype.apply; | |
const _call = Function.prototype.call; | |
_apply.apply = _apply; | |
_call.apply = _apply; | |
Function.prototype.toString.apply = _apply; | |
Array.prototype.slice.apply = _apply; | |
console.trace.apply = _apply; | |
function log(t, a) { | |
console.log("Calling", | |
Function.prototype.toString.apply(t, []), | |
"with:", | |
Array.prototype.slice.apply(a, [1]).toString() | |
); | |
console.trace.apply(console, []); | |
} | |
Function.prototype.call = function () { | |
log(this, arguments); | |
_call.apply(this, arguments); | |
}; | |
Function.prototype.apply = function () { | |
log(this, arguments); | |
_apply.apply(this, arguments); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment