Installations
npm install caller-path
Developer Guide
Typescript
No
Module System
ESM
Min. Node Version
^12.20.0 || ^14.13.1 || >=16.0.0
Node Version
16.10.0
NPM Version
7.20.3
Score
99.6
Supply Chain
93.6
Quality
75.4
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (85.32%)
TypeScript (14.68%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
sindresorhus
Download Statistics
Total Downloads
2,964,156,693
Last Day
1,242,850
Last Week
8,061,964
Last Month
29,575,981
Last Year
337,496,869
GitHub Statistics
MIT License
64 Stars
19 Commits
11 Forks
7 Watchers
1 Branches
5 Contributors
Updated on Jan 07, 2025
Bundle Size
601.00 B
Minified
335.00 B
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
4.0.0
Package Id
caller-path@4.0.0
Size
2.07 kB
NPM Version
7.20.3
Node Version
16.10.0
Published on
Oct 08, 2021
Total Downloads
Cumulative downloads
Total Downloads
2,964,156,693
Last Day
-17.5%
1,242,850
Compared to previous day
Last Week
15.8%
8,061,964
Compared to previous week
Last Month
52.9%
29,575,981
Compared to previous month
Last Year
-15.2%
337,496,869
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
4
caller-path
Get the path of the caller function
Install
1npm install caller-path
Usage
1// foo.js 2import callerPath from 'caller-path'; 3 4export default function foo() { 5 console.log(callerPath()); 6 //=> '/Users/sindresorhus/dev/unicorn/bar.js' 7}
1// bar.js 2import foo from './foo.js'; 3foo();
If the caller's callsite object getFileName
was not defined for some reason, it will return undefined
.
API
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:
1// foo.js 2import callerPath from 'caller-path'; 3 4export default function foo() { 5 console.log(callerPath()); 6 //=> '/Users/sindresorhus/dev/unicorn/foobar.js' 7 console.log(callerPath({depth: 1})); 8 //=> '/Users/sindresorhus/dev/unicorn/bar.js' 9 console.log(callerPath({depth: 2})); 10 //=> '/Users/sindresorhus/dev/unicorn/foo.js' 11}
1// bar.js 2import foo from './foo.js'; 3 4export default function bar() { 5 foo(); 6}
1// foobar.js 2import bar from './bar.js'; 3bar();
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
security policy file detected
Details
- Info: security policy file detected: .github/security.md:1
- Info: Found linked content: .github/security.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: .github/security.md:1
- Info: Found text in security policy: .github/security.md:1
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
Found 4/19 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/caller-path/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/caller-path/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:22
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 4 are checked with a SAST tool
Score
4.2
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More