//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` ?
}
How do you find out the caller function which is in different file in JavaScript?
I've seen a similar answer in this question.
But I got this logging :
debug: caller is function wrapper() {
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
return fn.apply(thisArg, arguments);
}