You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
744 B

4 years ago
  1. # caller-callsite [![Build Status](https://travis-ci.org/sindresorhus/caller-callsite.svg?branch=master)](https://travis-ci.org/sindresorhus/caller-callsite)
  2. > Get the [callsite](https://github.com/sindresorhus/callsites#api) of the caller function
  3. ## Install
  4. ```
  5. $ npm install --save caller-callsite
  6. ```
  7. ## Usage
  8. ```js
  9. // foo.js
  10. const callerCallsite = require('caller-callsite');
  11. module.exports = () => {
  12. console.log(callerCallsite().getFileName());
  13. //=> '/Users/sindresorhus/dev/unicorn/bar.js'
  14. }
  15. ```
  16. ```js
  17. // bar.js
  18. const foo = require('./foo');
  19. foo();
  20. ```
  21. ## API
  22. ### callerCallsite()
  23. Returns a [`callsite`](https://github.com/sindresorhus/callsites#api) object.
  24. ## License
  25. MIT © [Sindre Sorhus](https://sindresorhus.com)