How do you find out the caller function which is in different file?
<pre><code>//foo.js

module.exports.foo = function foo() {
    //
}

// Bar.js

var f = require(./foo);

function bar() {
    f.foo(); // How to find out the caller function is `foo` ?
}
</code></pre>

<p>How do you find out the caller function which is <strong>in different file</strong> in JavaScript?</p>

<p>I've seen a similar answer in <a href="https://stackoverflow.com/a/280396/4234171">this question</a>.</p>

<p>But I got this logging : </p>

<pre><code>debug: caller is function wrapper() {
    var fn = (this &amp;&amp; this !== root &amp;&amp; this instanceof wrapper) ? Ctor : func;
    return fn.apply(thisArg, arguments);
  }
</code></pre>