@expo/metro-runtime
Version:
Tools for making advanced Metro bundler features work
21 lines (17 loc) • 522 B
text/typescript
import { parse, StackFrame } from 'stacktrace-parser';
function parseErrorStack(stack?: string): (StackFrame & { collapse?: boolean })[] {
if (stack == null) {
return [];
}
if (Array.isArray(stack)) {
return stack;
}
return parse(stack).map((frame) => {
// frame.file will mostly look like `http://localhost:8081/index.bundle?platform=web&dev=true&hot=false`
return {
...frame,
column: frame.column != null ? frame.column - 1 : null,
};
});
}
export default parseErrorStack;