• Get an array of @tapjs/stack!call-site-like.CallSiteLike objects for the current location, from the call to the fn argument supplied, limited to the number of frames specified by limit.

    If the limit argument is 0, then the current Error.stackTraceLimit value will be used.

    This method is not re-entry safe, due to the fact that it relies on temporarily overriding the global Error.prepareStackTrace. As a result, if a capture() is triggered in any of the methods used by the CallSiteLike constructor (for example, if @tapjs/intercept is used to capture the process.cwd() method, which is used by path.resolve()), then that will cause problems. To work around this, if a re-entry is detected, then an empty stack of [] is returned.

    Even if it was made re-entry safe, it would be easy to accidentally trigger an infinite recursion and stack overflow in such a scenario, so returning an empty stack in the case of re-entry is the best workaround.

    Parameters

    • limit: number
    • fn: Function | ((...a: any[]) => any)

    Returns CallSiteLike[]

  • Parameters

    • limit: number

    Returns CallSiteLike[]

  • Parameters

    • fn: Function | ((...a: any[]) => any)

    Returns CallSiteLike[]

  • Returns CallSiteLike[]