New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modify wrapFunction to use original function toString #9
Conversation
screeps-profiler.js
Outdated
@@ -95,6 +95,14 @@ function wrapFunction(name, originalFunction) { | |||
|
|||
return originalFunction.apply(this, arguments); | |||
}; | |||
|
|||
wrappedFunction.toString = function() { | |||
return "// screeps-profiler wrapped function:\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use string templating:
return `// screeps-profiler wrapped function:\n${originalFunction.toString()}`
@sparr Could you provide me with your reason for this change? Example use case maybe? |
The purpose of this is to re-enable the ability to put the name of a function/method into the console and get back its source. |
Ah, like typing |
I had the bad luck to upload this during the big DNS DDOS that affected github and a zillion other sites, so GH couldn't talk to Travis at the time. I'll make some changes when I can and re-commit. This is low priority right now because this functionality was ALSO later doubly-broken by some security changes in the core game. Devs have said it wasn't intentional but they aren't bringing it back yet, but now that the private server is open source I can submit a patch to them to fix it, too. |
@sparr poke. I've been trying to clean up the pending PRs. On this repo today, can you update the string and fix the linting issues?
|
I haven't been playing screeps lately. Feel free to close this if you want. I'll come back to it some day, I hope. |
No worries. I think I've got edit ability, I can fix it up. I'm in the same
boat, I really just maintain this repo (poorly) and admin the slack
(delegated).
…On Thu, Apr 27, 2017, 10:56 AM sparr ***@***.***> wrote:
I haven't been playing screeps lately. Feel free to close this if you
want. I'll come back to it some day, I hope.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AD-pI8_TLK7dd2heilvoq3Zjrb5G3B9eks5r0NasgaJpZM4KdY2Y>
.
|
…als. Wrapping functions was making it difficult to call toString() on functions to get their content, and led to harder debugging. By overriding the wrapper function's toString, we're able to print out the original content of the wrapped functions.
No description provided.