Socket
Socket
Sign inDemoInstall

get-caller-file

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    get-caller-file

[![Build Status](https://travis-ci.org/stefanpenner/get-caller-file.svg?branch=master)](https://travis-ci.org/stefanpenner/get-caller-file) [![Build status](https://ci.appveyor.com/api/projects/status/ol2q94g1932cy14a/branch/master?svg=true)](https://ci.a


Version published
Weekly downloads
43M
decreased by-0.83%
Maintainers
1
Created
Weekly downloads
 

Package description

What is get-caller-file?

The get-caller-file package is designed to help developers retrieve the path of the file that calls a function. This can be particularly useful for debugging, logging, or tracking the flow of execution in complex applications where functions might be called from various locations.

What are get-caller-file's main functionalities?

Getting the path of the caller file

This feature allows developers to easily identify the file path of the code that called a function. By using `getCallerFile` within a function, it logs the path of the file that initiated the call, aiding in debugging and tracking execution flow.

const getCallerFile = require('get-caller-file');
function someFunction() {
  console.log(getCallerFile());
}

Other packages similar to get-caller-file

Readme

Source

get-caller-file

Build Status Build status

This is a utility, which allows a function to figure out from which file it was invoked. It does so by inspecting v8's stack trace at the time it is invoked.

Inspired by http://stackoverflow.com/questions/13227489

note: this relies on Node/V8 specific APIs, as such other runtimes may not work

Installation

yarn add get-caller-file

Usage

Given:

// ./foo.js
const getCallerFile = require('get-caller-file');

module.exports = function() {
  return getCallerFile(); // figures out who called it
};
// index.js
const foo = require('./foo');

foo() // => /full/path/to/this/file/index.js

Options:

  • getCallerFile(position = 2): where position is stack frame whos fileName we want.

FAQs

Last updated on 09 Mar 2019

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc