()
| 31 | * @returns {string[]} |
| 32 | */ |
| 33 | export function get_stack() { |
| 34 | // @ts-ignore - doesn't exist everywhere |
| 35 | const limit = Error.stackTraceLimit; |
| 36 | // @ts-ignore - doesn't exist everywhere |
| 37 | Error.stackTraceLimit = Infinity; |
| 38 | const stack = new Error().stack; |
| 39 | // @ts-ignore - doesn't exist everywhere |
| 40 | Error.stackTraceLimit = limit; |
| 41 | |
| 42 | if (!stack) return []; |
| 43 | |
| 44 | const lines = stack.split('\n'); |
| 45 | const new_lines = []; |
| 46 | |
| 47 | for (let i = 0; i < lines.length; i++) { |
| 48 | const line = lines[i]; |
| 49 | const posixified = line.replaceAll('\\', '/'); |
| 50 | |
| 51 | if (line.trim() === 'Error') { |
| 52 | continue; |
| 53 | } |
| 54 | |
| 55 | if (line.includes('validate_each_keys')) { |
| 56 | return []; |
| 57 | } |
| 58 | |
| 59 | if (posixified.includes('svelte/src/internal') || posixified.includes('node_modules/.vite')) { |
| 60 | continue; |
| 61 | } |
| 62 | |
| 63 | new_lines.push(line); |
| 64 | } |
| 65 | |
| 66 | return new_lines; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * @param {boolean} condition |
no test coverage detected