callers-path
V8 stacktrace API based caller's path
install
npm install --save callers-path
usage
example/moduleB.js
var callersPath = ;module{ console;};
example/moduleA.js
var moduleB = ; ;// => example/moduleA.js
documentation
require('callers-path')([frames, origin])
frames
if specified should be aninteger
bigger than0
orInfinity
.origin
if specified should be a function.- if no arguments, the default number of
frames
is2
so theorigin
is the module itself. The stack is sliced by one.
why
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.
inspirated by
It serves for the same use cases implemented on this cool modules
test
npm test