(stack: string[])
| 31 | const regexValidFrame_FireFox = /(^|@)\S+:\d+|.+line\s+\d+\s+>\s+(eval|Function).+/; |
| 32 | |
| 33 | function 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. |
no test coverage detected