Socket
Socket
Sign inDemoInstall

caller-path

Package Overview
Dependencies
2
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 3.0.0

index.d.ts

2

index.js
'use strict';
const callerCallsite = require('caller-callsite');
module.exports = () => callerCallsite().getFileName();
module.exports = ({depth = 0} = {}) => callerCallsite({depth}).getFileName();
{
"name": "caller-path",
"version": "2.0.0",
"description": "Get the path of the caller function",
"license": "MIT",
"repository": "sindresorhus/caller-path",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"caller",
"calling",
"module",
"path",
"parent",
"callsites",
"callsite",
"stacktrace",
"stack",
"trace",
"function",
"file"
],
"dependencies": {
"caller-callsite": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
},
"xo": {
"esnext": true
}
"name": "caller-path",
"version": "3.0.0",
"description": "Get the path of the caller function",
"license": "MIT",
"repository": "sindresorhus/caller-path",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"caller",
"calling",
"module",
"path",
"parent",
"callsites",
"callsite",
"stacktrace",
"stack",
"trace",
"function",
"file"
],
"dependencies": {
"caller-callsite": "^4.1.0"
},
"devDependencies": {
"ava": "^2.4.0",
"tsd": "^0.11.0",
"xo": "^0.25.3"
}
}

@@ -5,2 +5,3 @@ # caller-path [![Build Status](https://travis-ci.org/sindresorhus/caller-path.svg?branch=master)](https://travis-ci.org/sindresorhus/caller-path)

**Important:** You have to use `'use strict';` in your code for this module to work correctly, or make sure the module is an ESM module, which is implicitly strict.

@@ -10,6 +11,5 @@ ## Install

```
$ npm install --save caller-path
$ npm install caller-path
```
## Usage

@@ -33,5 +33,58 @@

If the caller's [callsite](https://github.com/sindresorhus/callsites#api) object `getFileName` was not defined for some reason, it will return `undefined`.
## License
## API
MIT © [Sindre Sorhus](https://sindresorhus.com)
### callerPath(options?)
Get the path of the caller function.
##### depth
Type: `number`\
Default: `0`
The caller path depth, meaning how many levels we follow back on the stack trace.
For example:
```js
// foo.js
const callerPath = require('caller-path');
module.exports = () => {
console.log(callerPath());
//=> '/Users/sindresorhus/dev/unicorn/foobar.js'
console.log(callerPath({depth: 1}));
//=> '/Users/sindresorhus/dev/unicorn/bar.js'
console.log(callerPath({depth: 2}));
//=> '/Users/sindresorhus/dev/unicorn/foo.js'
}
```
```js
// bar.js
const foo = require('./foo');
module.exports = () => {
foo();
}
```
```js
// foobar.js
const bar = require('./bar');
bar();
```
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-caller-path?utm_source=npm-caller-path&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>

Sorry, the diff of this file is not supported yet

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