UNPKG

get-stack-trace

Version:

Stack traces as an array of stack frames with source maps support.

30 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getStackTrace = void 0; const stacktrace_parser_1 = require("stacktrace-parser"); const getStackTrace = () => { // The reason we are parsing the stack trace rather than // using captureStackTrace is because captureStackTrace // does not resolve source maps, i.e. the stack trace // will contain the compiled code references rather than // the original source code references. // // eslint-disable-next-line unicorn/error-message const stackTrace = new Error().stack; if (!stackTrace) { throw new Error('Could not get stack trace'); } return (0, stacktrace_parser_1.parse)(stackTrace) .map((stackFrame) => { return { arguments: stackFrame.arguments, columnNumber: stackFrame.column, fileName: stackFrame.file, functionName: stackFrame.methodName, lineNumber: stackFrame.lineNumber, }; }) .slice(1); }; exports.getStackTrace = getStackTrace; //# sourceMappingURL=getStackTrace.js.map