error-stack-parser-es

Cross-browser Error parser

MIT 8 个版本
安装
npm install error-stack-parser-es
yarn add error-stack-parser-es
pnpm add error-stack-parser-es
bun add error-stack-parser-es
README

error-stack-parser-es

NPM version

A port of stacktracejs/error-stack-parser, rewrite with TypeScript and ES Modules.

Usage

import { parse } from 'error-stack-parser-es'

const stacktrace = parse(new Error('BOOM!'))

Refer to stacktracejs/error-stack-parser for more details.

Lite API

Additionally, this fork added a lite version of the API representation for the stack frames. You can import it from error-stack-parser-es/lite. For example, line and col instead of lineNumber and columnNumber.

import { parse } from 'error-stack-parser-es/lite'

const stacktrace = parse(new Error('BOOM!'))
// [{ file: 'file.js', name: 'method', line: 1, col: 2}]

It also allows you to parse directly from a stacktrace string (which does not support Opera stacktrace format).

import { parseStack } from 'error-stack-parser-es/lite'

const stacktrace = parseStack('Error\n    at method (file.js:1:2)')
// [{ file: 'file.js', name: 'method', line: 1, col: 2}]

License

MIT License © 2023-PRESENT Anthony Fu MIT License © 2017 Eric Wendelin

版本列表
1.0.5 2025-01-09
0.1.5 2024-07-17
0.1.4 2024-05-14
0.1.3 2024-05-13
0.1.2 2024-05-13
0.1.1 2023-08-12
0.1.0 2023-07-12
0.0.0 2023-07-12