Irina Glushko 2389e7160b HW1 done | 3 lat temu | |
---|---|---|
.. | ||
node_modules | 3 lat temu | |
index.js | 3 lat temu | |
license | 3 lat temu | |
package.json | 3 lat temu | |
readme.md | 3 lat temu |
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