Socket
Socket
Sign inDemoInstall

caller-path

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    caller-path

Get the path of the caller module


Version published
Weekly downloads
6.2M
decreased by-1.18%
Maintainers
1
Install size
6.04 kB
Created
Weekly downloads
 

Package description

What is caller-path?

The caller-path npm package is designed to help developers retrieve the path of the file that calls a function. This can be particularly useful for debugging, logging, and tracking the flow of a program, especially in complex applications where functions are called from multiple places.

What are caller-path's main functionalities?

Get caller file path

This feature allows developers to log or retrieve the path of the file that called a function. In the provided code, the function `whoCalled` uses `callerPath()` to print the path of the caller file.

const callerPath = require('caller-path');

function whoCalled() {
  console.log(callerPath());
}

module.exports = whoCalled;

Other packages similar to caller-path

Readme

Source

caller-path Build Status

Get the path of the caller module

You can't use module.parent as modules are cached and it will return the first caller module, not necessarily the current one.

Install

$ npm install --save caller-path

Usage

// foo.js
var callerPath = require('caller-path');

module.exports = function () {
	console.log(callerPath());
	//=> /Users/sindresorhus/dev/unicorn/bar.js
}
// bar.js
var foo = require('./foo');
foo();

License

MIT © Sindre Sorhus

Keywords

FAQs

Last updated on 19 Apr 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc