It seems like an unnecessary change - if the source needs to be accessed then get the source file.
It seems like an unnecessary change - if the source needs to be accessed then get the source file.
Usually it doesn't matter, because these methods are used on functions that luckily only use well known names, mainly properties of window/global.
But it's a risk, and I've seen subtle bugs caused by the assumption that the function's .toString() can be run through text substitutions and eval to get back a variant of the original code.
Contrived example:
let x = "wrong variable";
function f() { let x = "I am x"; return function g() { return x; } }
f()()
=> 'I am x'
eval(f().toString())
g()
=> 'wrong variable'I know this because I have wanted to use fn.toString() as part of some meta-programming many years ago (but couldn't because comments were not stored).
I am sure a lot of effort went in to making a good decision, aiming for a good outcome, but this smells like a bad one.