A Node.js module to parse JavaScript stack traces generated by browsers, and try to extract as much information from them as possible.
Uses code from the awesome stacktracejs project.
Parses stack traces from Chrome, Firefox, Opera, Safari and IE>=10.
var parse = require("browser-stack-parser");
var stack = "ReferenceError: nonExistantFunction is not defined\n at fn3 (http://localhost:3000/stackgen.js:10:2)\n at fn2 (http://localhost:3000/stackgen.js:6:2)\n at fn1 (http://localhost:3000/stackgen.js:2:2)\n at http://localhost:3000/stackgen.js:14:2"
console.log(parse(stack));
/*
Should output the following:
[
{url: "http://localhost:3000/stackgen.js", func: "fn3", line: 10, column: 2},
{url: "http://localhost:3000/stackgen.js", func: "fn2", line: 6, column: 2},
{url: "http://localhost:3000/stackgen.js", func: "fn1", line: 2, column: 2},
{url: "http://localhost:3000/stackgen.js", func: "<unknown>", line: 14, column: 2}
]
*/
npm install browser-stack-parser
To run tests, cd
to the browser-stack-parser
directory, and run npm test
.
If you want to add a test for different browsers, you can simply open test/helpers/index.html
in a browser to see the stacktrace generated by that browser.
MIT