Irina Glushko 2389e7160b HW1 done | 3 years ago | |
---|---|---|
.. | ||
node_modules | 3 years ago | |
index.js | 3 years ago | |
license | 3 years ago | |
package.json | 3 years ago | |
readme.md | 3 years ago |
Get the callsite of the caller function
$ npm install --save caller-callsite
// foo.js
const callerCallsite = require('caller-callsite');
module.exports = () => {
console.log(callerCallsite().getFileName());
//=> '/Users/sindresorhus/dev/unicorn/bar.js'
}
// bar.js
const foo = require('./foo');
foo();
Returns a callsite
object.
MIT © Sindre Sorhus