UNPKG

msw

Version:

Seamless REST/GraphQL API mocking library for browser and Node.js.

21 lines 659 B
const SOURCE_FRAME = /[\/\\]msw[\/\\]src[\/\\](.+)/; const BUILD_FRAME = /(node_modules)?[\/\\]lib[\/\\](core|browser|node|native|iife)[\/\\]|^[^\/\\]*$/; function getCallFrame(error) { const stack = error.stack; if (!stack) { return; } const frames = stack.split("\n").slice(1); const declarationFrame = frames.find((frame) => { return !(SOURCE_FRAME.test(frame) || BUILD_FRAME.test(frame)); }); if (!declarationFrame) { return; } const declarationPath = declarationFrame.replace(/\s*at [^()]*\(([^)]+)\)/, "$1").replace(/^@/, ""); return declarationPath; } export { getCallFrame }; //# sourceMappingURL=getCallFrame.mjs.map