Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
caller-dirname
Advanced tools
Get the directory name of a caller function's containing file.
$ npm i caller-dirname
/home/detrohutt/test/caller-dirname/callee.js
import { callerDirname } from 'caller-dirname';
export default () => callerDirname();
/home/detrohutt/test/caller-dirname/deeper/caller.js
import thisDirname from '../callee.js';
console.log(thisDirname()); /* /home/detrohutt/test/caller-dirname/deeper */
Option | Default | Description |
---|---|---|
depth | 1 | Depth sets the position in the call stack at which you want to retrieve the directory name. With the default depth of 1 (1st caller) you get the dirname of the function that directly calls callerDirname() (we'll call it fn1 ). With a depth of 2 (2nd caller), you'd instead get the dirname of the function that called fn1 , etc. |
import { callerDirname } from 'caller-dirname';
export const thirdCallerDir = () => callerDirname({ depth: 3 });
I needed this for another repo I'm working on. Most of the code is taken from caller-path. The main difference is this returns the dirname only, rather than the full path with filename and extension. Also, it's published both as a CommonJS module and as an ES Module and includes TypeScript typings.
FAQs
Get the directory name of a caller function's containing file.
The npm package caller-dirname receives a total of 2,229 weekly downloads. As such, caller-dirname popularity was classified as popular.
We found that caller-dirname demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.