Last active
September 29, 2020 10:03
-
-
Save NateScarlet/6717763f50f0183f4be8a4587d19a3d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { wrapCallSite } from 'source-map-support'; | |
export default function captureStackTrace(skip = 0): NodeJS.CallSite[] { | |
const rawPrepareStackTrace = Error.prepareStackTrace; | |
try { | |
Error.prepareStackTrace = (_, stack) => stack; | |
const v: { stack: NodeJS.CallSite[] } = { stack: [] }; | |
Error.captureStackTrace(v); | |
return v.stack.slice(1 + skip).map(i => wrapCallSite(i)); | |
} finally { | |
Error.prepareStackTrace = rawPrepareStackTrace; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment