Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

caller

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caller

@substack's caller.js as a module

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
203K
-9.07%
Maintainers
2
Weekly downloads
 
Created
Source

caller

Figure out your caller (thanks to @substack).

Initialization Time Caller
// foo.js

var bar = require('bar');
// bar.js

var caller = require('caller');
console.log(caller()); // `/path/to/foo.js`
Runtime Caller
// foo.js

var bar = require('bar');
bar.doWork();
// bar.js

var caller = require('caller');

exports.doWork = function () {
    console.log(caller());  // `/path/to/foo.js`
};

Depth

Caller also accepts a depth argument for tracing back further (defaults to 1).

// foo.js

var bar = require('bar');
bar.doWork();
// bar.js

var baz = require('baz');

exports.doWork = function () {
    baz.doWork();
};
// baz.js

var caller = require('caller');

exports.doWork = function () {
    console.log(caller(2));  // `/path/to/foo.js`
};

Keywords

caller

FAQs

Package last updated on 10 Mar 2022

Did you know?

Socket

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.

Install

Related posts