MCPcopy Index your code
hub / github.com/react/create-react-app / parseStack

Function parseStack

packages/react-error-overlay/src/utils/parser.js:33–69  ·  view source on GitHub ↗
(stack: string[])

Source from the content-addressed store, hash-verified

31const regexValidFrame_FireFox = /(^|@)\S+:\d+|.+line\s+\d+\s+>\s+(eval|Function).+/;
32
33function parseStack(stack: string[]): StackFrame[] {
34 const frames = stack
35 .filter(
36 e => regexValidFrame_Chrome.test(e) || regexValidFrame_FireFox.test(e)
37 )
38 .map(e => {
39 if (regexValidFrame_FireFox.test(e)) {
40 // Strip eval, we don't care about it
41 let isEval = false;
42 if (/ > (eval|Function)/.test(e)) {
43 e = e.replace(
44 / line (\d+)(?: > eval line \d+)* > (eval|Function):\d+:\d+/g,
45 ':$1'
46 );
47 isEval = true;
48 }
49 const data = e.split(/[@]/g);
50 const last = data.pop();
51 return new StackFrame(
52 data.join('@') || (isEval ? 'eval' : null),
53 ...extractLocation(last)
54 );
55 } else {
56 // Strip eval, we don't care about it
57 if (e.indexOf('(eval ') !== -1) {
58 e = e.replace(/(\(eval at [^()]*)|(\),.*$)/g, '');
59 }
60 if (e.indexOf('(at ') !== -1) {
61 e = e.replace(/\(at /, '(');
62 }
63 const data = e.trim().split(/\s+/g).slice(1);
64 const last = data.pop();
65 return new StackFrame(data.join(' ') || null, ...extractLocation(last));
66 }
67 });
68 return frames;
69}
70
71/**
72 * Turns an <code>Error</code>, or similar object, into a set of <code>StackFrame</code>s.

Callers 1

parseErrorFunction · 0.70

Calls 2

testMethod · 0.80
extractLocationFunction · 0.70

Tested by

no test coverage detected