V8 stacktrace API based caller's path
npm install --save callers-path
example/moduleB.js
var callersPath = require('callers-path');
module.exports = function(){
console.log(callersPath());
};example/moduleA.js
var moduleB = require('./moduleB');
moduleB();
// => example/moduleA.jsrequire('callers-path')([frames, origin])
framesif specified should be anintegerbigger than0orInfinity.originif specified should be a function.- if no arguments, the default number of
framesis2so theoriginis the module itself. The stack is sliced by one.
You would like to set how many frames are recorded (Error.stackTraceLimit) and from which function the stack should be traced back (Error.captureStackTrace).
By default two frames are recorded, though you can even lower it to one providing a function from which start.
It serves for the same use cases implemented on this cool modules
npm test