Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ Retrace.prototype.map = function(stack) {
});
};


Retrace.prototype.getStackInfo = function(stack) {
return Promise.all(parser.parse(stack).map(this.mapFrame, this))
.then(function(frames) {
var msg = /^.*$/m.exec(stack)[0];
var reMappedStack = msg + '\n' + frames.map(function(f) {
var pos = f.source;
if (f.line) pos += ':' + f.line;
if (f.column >= 0) pos += ':' + f.column;
var loc = f.name ? f.name + '(' + pos + ')' : pos;
return ' at ' + loc;
}).join('\n');
var lastStack = frames[0];
var source = lastStack.source
var line = lastStack.line
var column = lastStack.column
return {stack: reMappedStack, source, line, column}
});
};

Retrace.prototype.mapFrame = function(f) {
return this.getSourceMapConsumer(f.fileName).then(function(sm) {
return sm.originalPositionFor({
Expand Down