Skip to content
Get the callsite of the caller function
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig
.gitattributes
.gitignore
.npmrc
.travis.yml
fixture.js
fixture2.js
fixture3.js
index.js
license
package.json
readme.md
test.js

readme.md

caller-callsite Build Status

Get the callsite of the caller function

Install

$ npm install caller-callsite

Usage

// 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();

API

callerCallsite()

Returns a callsite object.

License

MIT © Sindre Sorhus

You can’t perform that action at this time.