Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

caller-callsite

Package Overview
Dependencies
1
Maintainers
1
Versions
7
Issues
File Explorer

Advanced tools

caller-callsite

Get the callsite of the caller function

    5.0.0latest

Version published
Maintainers
1
Weekly downloads
7,346,973
decreased by-12.25%

Weekly downloads

Changelog

Source

Breaking

  • Require Node.js 12.20 (#11) e7358be
  • This package is now pure ESM. Please read this.

https://github.com/sindresorhus/caller-callsite/compare/v4.1.0...v5.0.0

Readme

Source

caller-callsite

Get the callsite of the caller function

Install

npm install caller-callsite

Usage

// foo.js import callerCallsite from 'caller-callsite'; export default function foo() { console.log(callerCallsite().getFileName()); //=> '/Users/sindresorhus/dev/unicorn/bar.js' } // bar.js import foo from './foo.js'; foo();

API

callerCallsite(options?)

Returns a callsite object.

options

Type: object

depth

Type: number
Default: 0

The callsite depth, meaning how many levels we follow back on the stack trace.

For example:

// foo.js import callerCallsite from 'caller-callsite'; export default function foo() { console.log(callerCallsite().getFileName()); //=> '/Users/sindresorhus/dev/unicorn/foobar.js' console.log(callerCallsite({depth: 1}).getFileName()); //=> '/Users/sindresorhus/dev/unicorn/bar.js' console.log(callerCallsite({depth: 2}).getFileName()); //=> '/Users/sindresorhus/dev/unicorn/foo.js' } // bar.js import foo from './foo.js'; export default function foo() { foo(); } // foobar.js import bar from './bar.js'; bar();
Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Keywords

FAQs

What is caller-callsite?

Get the callsite of the caller function

Is caller-callsite popular?

The npm package caller-callsite receives a total of 5,879,006 weekly downloads. As such, caller-callsite popularity was classified as popular.

Is caller-callsite well maintained?

We found that caller-callsite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 07 Oct 2021

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc