callerid

Allows you to retrieve the filename or directory path of the file that has required your file/module.

CallerId

Allows you to retrieve the filename or directory path of the file that has required your file/module.

$ npm install callerid
  • retrieve both the filename and the directory path
  • dirname retrieve the directory path instead of the filename

Initiate

var callerid = require('callerid');

Get last caller

var file = callerid(),
    dir  = callerid.dirname();

Custom Levels

//back two files 
callerid(2);
 
//directory path two files ago 
callerid.dirname(2);
$ npm install
$ npm test

(The MIT License)