Skip to main content

Stack

Helper functions relating to rewinding the call stack.

Functions

getCallingFunction()

function getCallingFunction(upStackBy, verbose): object;

Defined in: functions/stack.ts:21

Helper function to get the name and file path of the calling function.

This function handles both Node.js and Bun. (Bun implements the v8 stack trace API differently.)

Parameters

ParameterTypeDefault valueDescription
upStackBynumber1Optional. The number of functions to rewind in the calling stack. Default is 1.
verbosebooleanfalseOptional. Shows all of the stack frames. Default is false.

Returns

NameTypeDescriptionDefined in
filePathstringThe full file path to the file that contains the calling function.functions/stack.ts:29
functionNameundefined | stringThe name of the calling function. Can be undefined on the Bun runtime in certain contexts.functions/stack.ts:26

Throws

If the calling function cannot be determined.