caller-callsite

WebJar for caller-callsite

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

caller-callsite
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

caller-callsite
WebJar for caller-callsite
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/sindresorhus/caller-callsite

Download caller-callsite

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : callsites jar [2.0.0,3)

Project Modules

There are no modules declared in this project.

caller-callsite

Get the callsite of the caller function

Install

$ npm install caller-callsite

Usage

// foo.js
const callerCallsite = require('caller-callsite');

module.exports = () => {
	console.log(callerCallsite().getFileName());
	//=> '/Users/sindresorhus/dev/unicorn/bar.js'
}
// bar.js
const foo = require('./foo');
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
const callerCallsite = require('caller-callsite');

module.exports = () => {
	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
const foo = require('./foo');

module.exports = () => {
	foo();
}
// foobar.js
const bar = require('./bar');
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.

Versions

Version
2.0.0