Sha256: 36915508f87d175a6f851660e6054956a31fef00bd754904c8c63d1bf2dfc196
Contents?: true
Size: 976 Bytes
Versions: 26
Compression:
Stored size: 976 Bytes
Contents
// Ignore the source files traces for local testing. const SOURCE_FRAME = /[\/\\]msw[\/\\]src[\/\\](.+)/ const BUILD_FRAME = /(node_modules)?[\/\\]lib[\/\\](core|browser|node|native|iife)[\/\\]|^[^\/\\]*$/ /** * Return the stack trace frame of a function's invocation. */ export function getCallFrame(error: Error) { // In <IE11, new Error may return an undefined stack const stack = error.stack if (!stack) { return } const frames: string[] = stack.split('\n').slice(1) // Get the first frame that doesn't reference the library's internal trace. // Assume that frame is the invocation frame. const declarationFrame = frames.find((frame) => { return !(SOURCE_FRAME.test(frame) || BUILD_FRAME.test(frame)) }) if (!declarationFrame) { return } // Extract file reference from the stack frame. const declarationPath = declarationFrame .replace(/\s*at [^()]*\(([^)]+)\)/, '$1') .replace(/^@/, '') return declarationPath }
Version data entries
26 entries across 26 versions & 1 rubygems