Installations
npm install @alloc/caller-path
Developer Guide
Typescript
No
Module System
N/A
Min. Node Version
>=8
Node Version
14.13.1
NPM Version
6.14.8
Score
66.6
Supply Chain
94.5
Quality
75
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (84.23%)
TypeScript (15.77%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
aleclarson
Download Statistics
Total Downloads
486
Last Day
1
Last Week
2
Last Month
14
Last Year
74
GitHub Statistics
MIT License
17 Commits
1 Watchers
2 Branches
1 Contributors
Updated on Apr 14, 2021
Bundle Size
682.00 B
Minified
341.00 B
Minified + Gzipped
Package Meta Information
Latest Version
3.0.0
Package Id
@alloc/caller-path@3.0.0
Unpacked Size
5.00 kB
Size
2.18 kB
File Count
5
NPM Version
6.14.8
Node Version
14.13.1
Total Downloads
Cumulative downloads
Total Downloads
486
Last Day
0%
1
Compared to previous day
Last Week
-50%
2
Compared to previous week
Last Month
133.3%
14
Compared to previous month
Last Year
-33.3%
74
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
caller-path
Get the path of the caller function
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.
Fork that includes https://github.com/sindresorhus/caller-path/pull/9
Install
$ npm install caller-path
Usage
1// foo.js 2const callerPath = require('caller-path'); 3 4module.exports = () => { 5 console.log(callerPath()); 6 //=> '/Users/sindresorhus/dev/unicorn/bar.js' 7}
1// bar.js 2const foo = require('./foo'); 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 2const callerPath = require('caller-path'); 3 4module.exports = () => { 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 2const foo = require('./foo'); 3 4module.exports = () => { 5 foo(); 6}
1// foobar.js 2const bar = require('./bar'); 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 binaries found in the repo
Reason
no dangerous workflow patterns detected
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
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/aleclarson/caller-path/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/aleclarson/caller-path/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:23
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
Found 0/17 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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
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'
Score
4.1
/10
Last Scanned on 2025-02-10
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