get-caller-file

WebJar for get-caller-file

License

License

ISC
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

get-caller-file
Last Version

Last Version

2.0.5
Release Date

Release Date

Type

Type

jar
Description

Description

get-caller-file
WebJar for get-caller-file
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/stefanpenner/get-caller-file

Download get-caller-file

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/get-caller-file/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>get-caller-file</artifactId>
    <version>2.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/get-caller-file/
implementation 'org.webjars.npm:get-caller-file:2.0.5'
// https://jarcasting.com/artifacts/org.webjars.npm/get-caller-file/
implementation ("org.webjars.npm:get-caller-file:2.0.5")
'org.webjars.npm:get-caller-file:jar:2.0.5'
<dependency org="org.webjars.npm" name="get-caller-file" rev="2.0.5">
  <artifact name="get-caller-file" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='get-caller-file', version='2.0.5')
)
libraryDependencies += "org.webjars.npm" % "get-caller-file" % "2.0.5"
[org.webjars.npm/get-caller-file "2.0.5"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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.

Versions

Version
2.0.5
2.0.1
1.0.3
1.0.2