v8-callsites v1.2.1
v8-callsites

V8 stacktrace API callsites with knobs.
install
npm install --save v8-callsitesusage
var stack = require('v8-callsites');
origin();
function origin(){
foo();
}
function foo(){
bar();
}
function bar(){
baz();
}
function baz(){
var barStackFrombaz = stack(3, bar);
// bar `stack` from baz with only 3 frames
barstackFrombaz.forEach(function(frame){
console.log(
frame.getFunctionName(), '->', frame+''
);
});
}documentation
require('v8-callsites')([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 returned stack is sliced by one.
See also the avaliable methods of the stack trace api like:
getLineNumbergetFileNamegetEvalOrigin- etc.
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
I've been using those a lot.
test
npm testlicense
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago