diff --git a/README.md b/README.md
index 705e65b..213cf28 100644
--- a/README.md
+++ b/README.md
@@ -6,8 +6,8 @@


-A utility for tracing the caller's call sites starting from a specific callee.
-*Useful for debugging, logging, or building tools that need to get the call origins or file locations at runtime.*
+A utility for tracing the caller's call sites, starting after a specific callee.
+*Useful for debugging, logging, or building tools that need to get the call origin details at runtime.*
## Install
```bash
@@ -16,49 +16,84 @@ npm i @mnrendra/stack-trace
## API
-### **`stackTrace`**
-Traces the caller's call sites starting from a specific callee.
-*Captures the current stack trace as an array of `NodeJS.CallSite` objects. If a callee is provided, the trace will start from the caller of the callee.*
+### • `stackTrace`
+Traces the caller's call sites, starting after a specific callee.
+*Captures the current stack trace as an array of `NodeJS.CallSite`. If a callee is provided, the trace will start from the caller of the callee.*
-#### **Type**:
+#### Type
```typescript
(callee?: ((...args: any) => any) | null, options?: Options) => NodeJS.CallSite[]
```
#### Parameters
-
| Name | Type | Description |
|-----------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| `callee` | `((...args: any) => any) \| null` | Optional callee function or method to start tracing from. If `undefined` or `null`, tracing starts from the current caller. |
+| `callee` | `((...args: any) => any) \| null` | Optional callee function or method to start tracing after. If `undefined` or `null`, tracing starts from the current caller. |
| `options` | `Options` | Configuration options for tracing behavior. By default, the `limit` option is set to `Infinity` to capture all frames. To capture only a specific number of frames, set the `limit` option to a positive number. |
-#### **Return Type**:
+#### Return
```typescript
NodeJS.CallSite[]
```
-An array of call sites representing the captured stack trace.
+An array of `NodeJS.CallSite` representing the captured stack trace.
-## Usage
+#### Options
+| Name | Type | Default | Description |
+|---------|----------|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `limit` | `number` | `Infinity` | Specifies the number of stack frames to be collected by a stack trace. The default value is `Infinity` but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. |
+
+### • `getCallerSite`
+Gets the caller's call site, starting after a specific callee.
+*Returns the first call site from the current stack trace as a `NodeJS.CallSite`. If a callee is provided, the trace will start from the caller of the callee.*
+
+#### Type
+```typescript
+(callee?: ((...args: any) => any) | null) => NodeJS.CallSite
+```
-### **CommonJS**
+#### Parameters
+| Name | Type | Description |
+|-----------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------|
+| `callee` | `((...args: any) => any) \| null` | Optional callee function or method to start tracing after. If `undefined` or `null`, tracing starts from the current caller. |
+#### Return
+```typescript
+NodeJS.CallSite
+```
+A `NodeJS.CallSite` representing the first call site from the captured stack trace.
+
+## Usage
+
+### CommonJS
`/foo/callee.cjs`
```javascript
-const { stackTrace } = require('@mnrendra/stack-trace')
+const { stackTrace, getCallerSite } = require('@mnrendra/stack-trace')
const callee = () => {
+ // stackTrace:
const [callSite1] = stackTrace()
const [callSite2] = stackTrace(callee, { limit: 1 }) // set the `callee` function as the callee.
- console.log(callSite1.getFileName()) // output: /foo/callee.cjs
- console.log(callSite2.getFileName()) // output: /foo/caller.cjs
+ console.log(callSite1.getFileName()) // Output: /foo/callee.cjs
+ console.log(callSite2.getFileName()) // Output: /foo/caller.cjs
+
+ console.log(callSite1.getFunctionName()) // Output: callee
+ console.log(callSite2.getFunctionName()) // Output: caller
+
+ // getCallerSite:
+ const callerSite1 = getCallerSite()
+ const callerSite2 = getCallerSite(callee) // set the `callee` function as the callee.
+
+ console.log(callerSite1.getFileName()) // Output: /foo/callee.cjs
+ console.log(callerSite2.getFileName()) // Output: /foo/caller.cjs
- console.log(callSite1.getFunctionName()) // output: callee
- console.log(callSite2.getFunctionName()) // output: caller
+ console.log(callerSite1.getFunctionName()) // Output: callee
+ console.log(callerSite2.getFunctionName()) // Output: caller
}
module.exports = callee
```
+
`/foo/caller.cjs`
```javascript
const callee = require('./callee.cjs')
@@ -66,25 +101,36 @@ const caller = () => callee()
caller()
```
-### **ES Modules**
-
+### ES Modules
`/foo/callee.mjs`
```javascript
-import { stackTrace } from '@mnrendra/stack-trace'
+import { stackTrace, getCallerSite } from '@mnrendra/stack-trace'
const callee = () => {
+ // stackTrace:
const [callSite1] = stackTrace()
const [callSite2] = stackTrace(callee, { limit: 1 }) // set the `callee` function as the callee.
- console.log(callSite1.getFileName()) // output: file:///foo/callee.mjs
- console.log(callSite2.getFileName()) // output: file:///foo/caller.mjs
+ console.log(callSite1.getFileName()) // Output: file:///foo/callee.mjs
+ console.log(callSite2.getFileName()) // Output: file:///foo/caller.mjs
+
+ console.log(callSite1.getFunctionName()) // Output: callee
+ console.log(callSite2.getFunctionName()) // Output: caller
+
+ // getCallerSite:
+ const callerSite1 = getCallerSite()
+ const callerSite2 = getCallerSite(callee) // set the `callee` function as the callee.
- console.log(callSite1.getFunctionName()) // output: callee
- console.log(callSite2.getFunctionName()) // output: caller
+ console.log(callerSite1.getFileName()) // Output: file:///foo/callee.mjs
+ console.log(callerSite2.getFileName()) // Output: file:///foo/caller.mjs
+
+ console.log(callerSite1.getFunctionName()) // Output: callee
+ console.log(callerSite2.getFunctionName()) // Output: caller
}
export default callee
```
+
`/foo/caller.mjs`
```javascript
import callee from './callee.mjs'
@@ -93,51 +139,63 @@ caller()
```
**Note**:
-- When calling `getFileName` in an **ES Modules**, the file name will be returned as a **file URL** (e.g., `'file:///foo'`) instead of a **file path** (e.g., `'/foo'`).
-*You can use `url.fileURLToPath` to convert the **file URL** to a **file path**.*
+- In ES Modules, `getFileName` returns a **file URL** (e.g., `file:///foo`), instead of a **file path** (`/foo`).
+*Use `url.fileURLToPath` to convert it if needed.*
- By default `stackTrace` will capture all caller frames.
*To capture only a specific number of frames, set the `limit` option to a positive number.*
### Examples
-1. Call from your development project:
+
+1. **Call from your development project**
+
`/foo/project-name/src/index.mjs`:
```javascript
import { fileURLToPath } from 'node:url'
-import { stackTrace } from '@mnrendra/stack-trace'
+import { stackTrace, getCallerSite } from '@mnrendra/stack-trace'
+
+// stackTrace:
+const caller1 = () => stackTrace()
+const [callSite] = caller1()
+
+const fileName = callSite.getFileName()
+
+console.log(fileName) // Output: file:///foo/project-name/src/index.mjs
+console.log(fileURLToPath(fileName)) // Output: /foo/project-name/src/index.mjs
-const caller = () => stackTrace()
-const [stack] = caller()
+// getCallerSite:
+const caller2 = () => getCallerSite()
+const callerSite = caller2()
-const fileName = stack.getFileName()
+const fileName = callerSite.getFileName()
-console.log(fileName) // output: file:///foo/project-name/src/index.mjs
-console.log(fileURLToPath(fileName)) // output: /foo/project-name/src/index.mjs
+console.log(fileName) // Output: file:///foo/project-name/src/index.mjs
+console.log(fileURLToPath(fileName)) // Output: /foo/project-name/src/index.mjs
```
-2. Call from your production package:
+2. **Call from your production package**
+
`/foo/consumer/node_modules/module-name/dist/index.js`:
```javascript
"use strict";
-const { stackTrace } = require("@mnrendra/stack-trace");
+const { stackTrace, getCallerSite } = require("@mnrendra/stack-trace");
-const caller = () => stackTrace();
-const [stack] = caller();
+// stackTrace:
+const caller1 = () => stackTrace();
+const [callSite] = caller1();
-const fileName = stack.getFileName();
+const fileName = callSite.getFileName();
-console.log(fileName); // output: /foo/consumer/node_modules/module-name/dist/index.js
-```
+console.log(fileName); // Output: /foo/consumer/node_modules/module-name/dist/index.js
-## Options
+// getCallerSite:
+const caller2 = () => getCallerSite();
+const callerSite = caller2();
-### **`limit`**
-#### **Type:** `number`
-#### **Default:** `Infinity`
+const fileName = callerSite.getFileName();
-Specifies the number of stack frames to be collected by a stack trace.
-*The default value is `Infinity` but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.*
-*If set to a non-number value, or set to a negative number, stack traces will not capture any frames.*
+console.log(fileName); // Output: /foo/consumer/node_modules/module-name/dist/index.js
+```
## Types
```typescript
diff --git a/__tests__/__snapshots__/index.ts.snap b/__tests__/__snapshots__/index.ts.snap
index f43d84e..8db06d5 100644
--- a/__tests__/__snapshots__/index.ts.snap
+++ b/__tests__/__snapshots__/index.ts.snap
@@ -1,6 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`Test all APIs: Test \`stackTrace\` API: Should capture the current stack trace when the callee is \`null\`! 1`] = `
+exports[`Test all APIs: Test \`getCallerSite\` Should return the first call site from the caller stack trace when the callee is a specific function! 1`] = `CallSite {}`;
+
+exports[`Test all APIs: Test \`getCallerSite\` Should return the first call site from the current stack trace when the callee is \`null\`! 1`] = `CallSite {}`;
+
+exports[`Test all APIs: Test \`getCallerSite\` Should return the first call site from the current stack trace when the callee is \`undefined\`! 1`] = `CallSite {}`;
+
+exports[`Test all APIs: Test \`stackTrace\` API: Should only return the first stack trace frame when the \`limit\` option is set to \`1\`! 1`] = `
+[
+ CallSite {},
+]
+`;
+
+exports[`Test all APIs: Test \`stackTrace\` API: Should return the caller stack trace when the callee is a specific function! 1`] = `
[
CallSite {},
CallSite {},
@@ -21,7 +33,7 @@ exports[`Test all APIs: Test \`stackTrace\` API: Should capture the current stac
]
`;
-exports[`Test all APIs: Test \`stackTrace\` API: Should capture the current stack trace when the callee is \`undefined\`! 1`] = `
+exports[`Test all APIs: Test \`stackTrace\` API: Should return the current stack trace when the callee is \`null\`! 1`] = `
[
CallSite {},
CallSite {},
@@ -42,7 +54,7 @@ exports[`Test all APIs: Test \`stackTrace\` API: Should capture the current stac
]
`;
-exports[`Test all APIs: Test \`stackTrace\` API: Should capture the stack trace of the caller when the callee is a specific function! 1`] = `
+exports[`Test all APIs: Test \`stackTrace\` API: Should return the current stack trace when the callee is \`undefined\`! 1`] = `
[
CallSite {},
CallSite {},
@@ -62,9 +74,3 @@ exports[`Test all APIs: Test \`stackTrace\` API: Should capture the stack trace
CallSite {},
]
`;
-
-exports[`Test all APIs: Test \`stackTrace\` API: Should only capture the first stack trace frame when the \`limit\` option is set to \`1\`! 1`] = `
-[
- CallSite {},
-]
-`;
diff --git a/__tests__/index.ts b/__tests__/index.ts
index 4676d7b..ca910e6 100644
--- a/__tests__/index.ts
+++ b/__tests__/index.ts
@@ -1,24 +1,24 @@
import { testMethods } from '@tests/utils'
-import { stackTrace } from '..'
+import { stackTrace, getCallerSite } from '..'
describe('Test all APIs:', () => {
describe('Test `stackTrace` API:', () => {
- it('Should capture the current stack trace when the callee is `undefined`!', () => {
+ it('Should return the current stack trace when the callee is `undefined`!', () => {
const caller = (): NodeJS.CallSite[] => stackTrace()
const received = caller()
expect(received).toMatchSnapshot()
received.forEach(testMethods)
})
- it('Should capture the current stack trace when the callee is `null`!', () => {
+ it('Should return the current stack trace when the callee is `null`!', () => {
const caller = (): NodeJS.CallSite[] => stackTrace(null)
const received = caller()
expect(received).toMatchSnapshot()
received.forEach(testMethods)
})
- it('Should capture the stack trace of the caller when the callee is a specific function!', () => {
+ it('Should return the caller stack trace when the callee is a specific function!', () => {
const callee = (): NodeJS.CallSite[] => stackTrace(callee)
const caller = (): NodeJS.CallSite[] => callee()
const received = caller()
@@ -26,7 +26,7 @@ describe('Test all APIs:', () => {
received.forEach(testMethods)
})
- it('Should only capture the first stack trace frame when the `limit` option is set to `1`!', () => {
+ it('Should only return the first stack trace frame when the `limit` option is set to `1`!', () => {
const caller = (): NodeJS.CallSite[] => stackTrace(caller, { limit: 1 })
const received = caller()
expect(received).toHaveLength(1)
@@ -36,77 +36,178 @@ describe('Test all APIs:', () => {
describe('Test all methods of the first stack frame returned from the `stackTrace` API:', () => {
const caller = (): NodeJS.CallSite[] => stackTrace()
- const [stack] = caller()
+ const [callSite] = caller()
it('Should return `null` when the `getTypeName` method is invoked!', () => {
- const received = stack.getTypeName()
+ const received = callSite.getTypeName()
expect(received).toBeNull()
})
it('Should return the current `__filename` when the `getFileName` method is invoked!', () => {
- const received = stack.getFileName()
+ const received = callSite.getFileName()
const expected = __filename
expect(received).toBe(expected)
})
it('Should return any `number` when the `getLineNumber` method is invoked!', () => {
- const received = stack.getLineNumber()
+ const received = callSite.getLineNumber()
const expected = expect.any(Number)
expect(received).toEqual(expected)
})
it('Should return any `number` when the `getColumnNumber` method is invoked!', () => {
- const received = stack.getColumnNumber()
+ const received = callSite.getColumnNumber()
const expected = expect.any(Number)
expect(received).toEqual(expected)
})
it('Should return `null` when the `getMethodName` method is invoked!', () => {
- const received = stack.getMethodName()
+ const received = callSite.getMethodName()
expect(received).toBeNull()
})
it('Should return the caller name when the `getFunctionName` method is invoked!', () => {
- const received = stack.getFunctionName()
+ const received = callSite.getFunctionName()
const expected = 'caller'
expect(received).toBe(expected)
})
it('Should return `undefined` when the `getFunction` method is invoked!', () => {
- const received = stack.getFunction()
+ const received = callSite.getFunction()
expect(received).toBeUndefined()
})
it('Should return `undefined` when the `getThis` method is invoked!', () => {
- const received = stack.getThis()
+ const received = callSite.getThis()
expect(received).toBeUndefined()
})
it('Should return `undefined` when the `getEvalOrigin` method is invoked!', () => {
- const received = stack.getEvalOrigin()
+ const received = callSite.getEvalOrigin()
expect(received).toBeUndefined()
})
it('Should return `false` when the `isConstructor` method is invoked!', () => {
- const received = stack.isConstructor()
+ const received = callSite.isConstructor()
const expected = false
expect(received).toBe(expected)
})
it('Should return `false` when the `isEval` method is invoked!', () => {
- const received = stack.isEval()
+ const received = callSite.isEval()
const expected = false
expect(received).toBe(expected)
})
it('Should return `false` when the `isNative` method is invoked!', () => {
- const received = stack.isNative()
+ const received = callSite.isNative()
const expected = false
expect(received).toBe(expected)
})
it('Should return `true` when the `isToplevel` method is invoked!', () => {
- const received = stack.isToplevel()
+ const received = callSite.isToplevel()
+ const expected = true
+ expect(received).toBe(expected)
+ })
+ })
+ })
+
+ describe('Test `getCallerSite`', () => {
+ it('Should return the first call site from the current stack trace when the callee is `undefined`!', () => {
+ const caller = (): NodeJS.CallSite => getCallerSite()
+ const received = caller()
+ expect(received).toMatchSnapshot()
+ testMethods(received)
+ })
+
+ it('Should return the first call site from the current stack trace when the callee is `null`!', () => {
+ const caller = (): NodeJS.CallSite => getCallerSite(null)
+ const received = caller()
+ expect(received).toMatchSnapshot()
+ testMethods(received)
+ })
+
+ it('Should return the first call site from the caller stack trace when the callee is a specific function!', () => {
+ const caller = (): NodeJS.CallSite => getCallerSite(caller)
+ const received = caller()
+ expect(received).toMatchSnapshot()
+ testMethods(received)
+ })
+
+ describe('Test all methods of the caller site object:', () => {
+ const caller = (): NodeJS.CallSite => getCallerSite()
+ const callerSite = caller()
+
+ it('Should return `null` when the `getTypeName` method is invoked!', () => {
+ const received = callerSite.getTypeName()
+ expect(received).toBeNull()
+ })
+
+ it('Should return the current `__filename` when the `getFileName` method is invoked!', () => {
+ const received = callerSite.getFileName()
+ const expected = __filename
+ expect(received).toBe(expected)
+ })
+
+ it('Should return any `number` when the `getLineNumber` method is invoked!', () => {
+ const received = callerSite.getLineNumber()
+ const expected = expect.any(Number)
+ expect(received).toEqual(expected)
+ })
+
+ it('Should return any `number` when the `getColumnNumber` method is invoked!', () => {
+ const received = callerSite.getColumnNumber()
+ const expected = expect.any(Number)
+ expect(received).toEqual(expected)
+ })
+
+ it('Should return `null` when the `getMethodName` method is invoked!', () => {
+ const received = callerSite.getMethodName()
+ expect(received).toBeNull()
+ })
+
+ it('Should return the caller name when the `getFunctionName` method is invoked!', () => {
+ const received = callerSite.getFunctionName()
+ const expected = 'caller'
+ expect(received).toBe(expected)
+ })
+
+ it('Should return `undefined` when the `getFunction` method is invoked!', () => {
+ const received = callerSite.getFunction()
+ expect(received).toBeUndefined()
+ })
+
+ it('Should return `undefined` when the `getThis` method is invoked!', () => {
+ const received = callerSite.getThis()
+ expect(received).toBeUndefined()
+ })
+
+ it('Should return `undefined` when the `getEvalOrigin` method is invoked!', () => {
+ const received = callerSite.getEvalOrigin()
+ expect(received).toBeUndefined()
+ })
+
+ it('Should return `false` when the `isConstructor` method is invoked!', () => {
+ const received = callerSite.isConstructor()
+ const expected = false
+ expect(received).toBe(expected)
+ })
+
+ it('Should return `false` when the `isEval` method is invoked!', () => {
+ const received = callerSite.isEval()
+ const expected = false
+ expect(received).toBe(expected)
+ })
+
+ it('Should return `false` when the `isNative` method is invoked!', () => {
+ const received = callerSite.isNative()
+ const expected = false
+ expect(received).toBe(expected)
+ })
+
+ it('Should return `true` when the `isToplevel` method is invoked!', () => {
+ const received = callerSite.isToplevel()
const expected = true
expect(received).toBe(expected)
})
diff --git a/package-lock.json b/package-lock.json
index 2e42b3e..e1a6532 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -708,9 +708,9 @@
}
},
"node_modules/@esbuild/aix-ppc64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.2.tgz",
- "integrity": "sha512-wCIboOL2yXZym2cgm6mlA742s9QeJ8DjGVaL39dLN4rRwrOgOyYSnOaFPhKZGLb2ngj4EyfAFjsNJwPXZvseag==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.3.tgz",
+ "integrity": "sha512-W8bFfPA8DowP8l//sxjJLSLkD8iEjMc7cBVyP+u4cEv9sM7mdUCkgsj+t0n/BWPFtv7WWCN5Yzj0N6FJNUUqBQ==",
"cpu": [
"ppc64"
],
@@ -726,9 +726,9 @@
}
},
"node_modules/@esbuild/android-arm": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.2.tgz",
- "integrity": "sha512-NQhH7jFstVY5x8CKbcfa166GoV0EFkaPkCKBQkdPJFvo5u+nGXLEH/ooniLb3QI8Fk58YAx7nsPLozUWfCBOJA==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.3.tgz",
+ "integrity": "sha512-PuwVXbnP87Tcff5I9ngV0lmiSu40xw1At6i3GsU77U7cjDDB4s0X2cyFuBiDa1SBk9DnvWwnGvVaGBqoFWPb7A==",
"cpu": [
"arm"
],
@@ -744,9 +744,9 @@
}
},
"node_modules/@esbuild/android-arm64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.2.tgz",
- "integrity": "sha512-5ZAX5xOmTligeBaeNEPnPaeEuah53Id2tX4c2CVP3JaROTH+j4fnfHCkr1PjXMd78hMst+TlkfKcW/DlTq0i4w==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.3.tgz",
+ "integrity": "sha512-XelR6MzjlZuBM4f5z2IQHK6LkK34Cvv6Rj2EntER3lwCBFdg6h2lKbtRjpTTsdEjD/WSe1q8UyPBXP1x3i/wYQ==",
"cpu": [
"arm64"
],
@@ -762,9 +762,9 @@
}
},
"node_modules/@esbuild/android-x64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.2.tgz",
- "integrity": "sha512-Ffcx+nnma8Sge4jzddPHCZVRvIfQ0kMsUsCMcJRHkGJ1cDmhe4SsrYIjLUKn1xpHZybmOqCWwB0zQvsjdEHtkg==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.3.tgz",
+ "integrity": "sha512-ogtTpYHT/g1GWS/zKM0cc/tIebFjm1F9Aw1boQ2Y0eUQ+J89d0jFY//s9ei9jVIlkYi8AfOjiixcLJSGNSOAdQ==",
"cpu": [
"x64"
],
@@ -780,9 +780,9 @@
}
},
"node_modules/@esbuild/darwin-arm64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.2.tgz",
- "integrity": "sha512-MpM6LUVTXAzOvN4KbjzU/q5smzryuoNjlriAIx+06RpecwCkL9JpenNzpKd2YMzLJFOdPqBpuub6eVRP5IgiSA==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.3.tgz",
+ "integrity": "sha512-eESK5yfPNTqpAmDfFWNsOhmIOaQA59tAcF/EfYvo5/QWQCzXn5iUSOnqt3ra3UdzBv073ykTtmeLJZGt3HhA+w==",
"cpu": [
"arm64"
],
@@ -798,9 +798,9 @@
}
},
"node_modules/@esbuild/darwin-x64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.2.tgz",
- "integrity": "sha512-5eRPrTX7wFyuWe8FqEFPG2cU0+butQQVNcT4sVipqjLYQjjh8a8+vUTfgBKM88ObB85ahsnTwF7PSIt6PG+QkA==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.3.tgz",
+ "integrity": "sha512-Kd8glo7sIZtwOLcPbW0yLpKmBNWMANZhrC1r6K++uDR2zyzb6AeOYtI6udbtabmQpFaxJ8uduXMAo1gs5ozz8A==",
"cpu": [
"x64"
],
@@ -816,9 +816,9 @@
}
},
"node_modules/@esbuild/freebsd-arm64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.2.tgz",
- "integrity": "sha512-mLwm4vXKiQ2UTSX4+ImyiPdiHjiZhIaE9QvC7sw0tZ6HoNMjYAqQpGyui5VRIi5sGd+uWq940gdCbY3VLvsO1w==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.3.tgz",
+ "integrity": "sha512-EJiyS70BYybOBpJth3M0KLOus0n+RRMKTYzhYhFeMwp7e/RaajXvP+BWlmEXNk6uk+KAu46j/kaQzr6au+JcIw==",
"cpu": [
"arm64"
],
@@ -834,9 +834,9 @@
}
},
"node_modules/@esbuild/freebsd-x64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.2.tgz",
- "integrity": "sha512-6qyyn6TjayJSwGpm8J9QYYGQcRgc90nmfdUb0O7pp1s4lTY+9D0H9O02v5JqGApUyiHOtkz6+1hZNvNtEhbwRQ==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.3.tgz",
+ "integrity": "sha512-Q+wSjaLpGxYf7zC0kL0nDlhsfuFkoN+EXrx2KSB33RhinWzejOd6AvgmP5JbkgXKmjhmpfgKZq24pneodYqE8Q==",
"cpu": [
"x64"
],
@@ -852,9 +852,9 @@
}
},
"node_modules/@esbuild/linux-arm": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.2.tgz",
- "integrity": "sha512-UHBRgJcmjJv5oeQF8EpTRZs/1knq6loLxTsjc3nxO9eXAPDLcWW55flrMVc97qFPbmZP31ta1AZVUKQzKTzb0g==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.3.tgz",
+ "integrity": "sha512-dUOVmAUzuHy2ZOKIHIKHCm58HKzFqd+puLaS424h6I85GlSDRZIA5ycBixb3mFgM0Jdh+ZOSB6KptX30DD8YOQ==",
"cpu": [
"arm"
],
@@ -870,9 +870,9 @@
}
},
"node_modules/@esbuild/linux-arm64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.2.tgz",
- "integrity": "sha512-gq/sjLsOyMT19I8obBISvhoYiZIAaGF8JpeXu1u8yPv8BE5HlWYobmlsfijFIZ9hIVGYkbdFhEqC0NvM4kNO0g==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.3.tgz",
+ "integrity": "sha512-xCUgnNYhRD5bb1C1nqrDV1PfkwgbswTTBRbAd8aH5PhYzikdf/ddtsYyMXFfGSsb/6t6QaPSzxtbfAZr9uox4A==",
"cpu": [
"arm64"
],
@@ -888,9 +888,9 @@
}
},
"node_modules/@esbuild/linux-ia32": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.2.tgz",
- "integrity": "sha512-bBYCv9obgW2cBP+2ZWfjYTU+f5cxRoGGQ5SeDbYdFCAZpYWrfjjfYwvUpP8MlKbP0nwZ5gyOU/0aUzZ5HWPuvQ==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.3.tgz",
+ "integrity": "sha512-yplPOpczHOO4jTYKmuYuANI3WhvIPSVANGcNUeMlxH4twz/TeXuzEP41tGKNGWJjuMhotpGabeFYGAOU2ummBw==",
"cpu": [
"ia32"
],
@@ -906,9 +906,9 @@
}
},
"node_modules/@esbuild/linux-loong64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.2.tgz",
- "integrity": "sha512-SHNGiKtvnU2dBlM5D8CXRFdd+6etgZ9dXfaPCeJtz+37PIUlixvlIhI23L5khKXs3DIzAn9V8v+qb1TRKrgT5w==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.3.tgz",
+ "integrity": "sha512-P4BLP5/fjyihmXCELRGrLd793q/lBtKMQl8ARGpDxgzgIKJDRJ/u4r1A/HgpBpKpKZelGct2PGI4T+axcedf6g==",
"cpu": [
"loong64"
],
@@ -924,9 +924,9 @@
}
},
"node_modules/@esbuild/linux-mips64el": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.2.tgz",
- "integrity": "sha512-hDDRlzE6rPeoj+5fsADqdUZl1OzqDYow4TB4Y/3PlKBD0ph1e6uPHzIQcv2Z65u2K0kpeByIyAjCmjn1hJgG0Q==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.3.tgz",
+ "integrity": "sha512-eRAOV2ODpu6P5divMEMa26RRqb2yUoYsuQQOuFUexUoQndm4MdpXXDBbUoKIc0iPa4aCO7gIhtnYomkn2x+bag==",
"cpu": [
"mips64el"
],
@@ -942,9 +942,9 @@
}
},
"node_modules/@esbuild/linux-ppc64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.2.tgz",
- "integrity": "sha512-tsHu2RRSWzipmUi9UBDEzc0nLc4HtpZEI5Ba+Omms5456x5WaNuiG3u7xh5AO6sipnJ9r4cRWQB2tUjPyIkc6g==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.3.tgz",
+ "integrity": "sha512-ZC4jV2p7VbzTlnl8nZKLcBkfzIf4Yad1SJM4ZMKYnJqZFD4rTI+pBG65u8ev4jk3/MPwY9DvGn50wi3uhdaghg==",
"cpu": [
"ppc64"
],
@@ -960,9 +960,9 @@
}
},
"node_modules/@esbuild/linux-riscv64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.2.tgz",
- "integrity": "sha512-k4LtpgV7NJQOml/10uPU0s4SAXGnowi5qBSjaLWMojNCUICNu7TshqHLAEbkBdAszL5TabfvQ48kK84hyFzjnw==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.3.tgz",
+ "integrity": "sha512-LDDODcFzNtECTrUUbVCs6j9/bDVqy7DDRsuIXJg6so+mFksgwG7ZVnTruYi5V+z3eE5y+BJZw7VvUadkbfg7QA==",
"cpu": [
"riscv64"
],
@@ -978,9 +978,9 @@
}
},
"node_modules/@esbuild/linux-s390x": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.2.tgz",
- "integrity": "sha512-GRa4IshOdvKY7M/rDpRR3gkiTNp34M0eLTaC1a08gNrh4u488aPhuZOCpkF6+2wl3zAN7L7XIpOFBhnaE3/Q8Q==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.3.tgz",
+ "integrity": "sha512-s+w/NOY2k0yC2p9SLen+ymflgcpRkvwwa02fqmAwhBRI3SC12uiS10edHHXlVWwfAagYSY5UpmT/zISXPMW3tQ==",
"cpu": [
"s390x"
],
@@ -996,9 +996,9 @@
}
},
"node_modules/@esbuild/linux-x64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.2.tgz",
- "integrity": "sha512-QInHERlqpTTZ4FRB0fROQWXcYRD64lAoiegezDunLpalZMjcUcld3YzZmVJ2H/Cp0wJRZ8Xtjtj0cEHhYc/uUg==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.3.tgz",
+ "integrity": "sha512-nQHDz4pXjSDC6UfOE1Fw9Q8d6GCAd9KdvMZpfVGWSJztYCarRgSDfOVBY5xwhQXseiyxapkiSJi/5/ja8mRFFA==",
"cpu": [
"x64"
],
@@ -1014,9 +1014,9 @@
}
},
"node_modules/@esbuild/netbsd-arm64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.2.tgz",
- "integrity": "sha512-talAIBoY5M8vHc6EeI2WW9d/CkiO9MQJ0IOWX8hrLhxGbro/vBXJvaQXefW2cP0z0nQVTdQ/eNyGFV1GSKrxfw==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.3.tgz",
+ "integrity": "sha512-1QaLtOWq0mzK6tzzp0jRN3eccmN3hezey7mhLnzC6oNlJoUJz4nym5ZD7mDnS/LZQgkrhEbEiTn515lPeLpgWA==",
"cpu": [
"arm64"
],
@@ -1032,9 +1032,9 @@
}
},
"node_modules/@esbuild/netbsd-x64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.2.tgz",
- "integrity": "sha512-voZT9Z+tpOxrvfKFyfDYPc4DO4rk06qamv1a/fkuzHpiVBMOhpjK+vBmWM8J1eiB3OLSMFYNaOaBNLXGChf5tg==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.3.tgz",
+ "integrity": "sha512-i5Hm68HXHdgv8wkrt+10Bc50zM0/eonPb/a/OFVfB6Qvpiirco5gBA5bz7S2SHuU+Y4LWn/zehzNX14Sp4r27g==",
"cpu": [
"x64"
],
@@ -1050,9 +1050,9 @@
}
},
"node_modules/@esbuild/openbsd-arm64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.2.tgz",
- "integrity": "sha512-dcXYOC6NXOqcykeDlwId9kB6OkPUxOEqU+rkrYVqJbK2hagWOMrsTGsMr8+rW02M+d5Op5NNlgMmjzecaRf7Tg==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.3.tgz",
+ "integrity": "sha512-zGAVApJEYTbOC6H/3QBr2mq3upG/LBEXr85/pTtKiv2IXcgKV0RT0QA/hSXZqSvLEpXeIxah7LczB4lkiYhTAQ==",
"cpu": [
"arm64"
],
@@ -1068,9 +1068,9 @@
}
},
"node_modules/@esbuild/openbsd-x64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.2.tgz",
- "integrity": "sha512-t/TkWwahkH0Tsgoq1Ju7QfgGhArkGLkF1uYz8nQS/PPFlXbP5YgRpqQR3ARRiC2iXoLTWFxc6DJMSK10dVXluw==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.3.tgz",
+ "integrity": "sha512-fpqctI45NnCIDKBH5AXQBsD0NDPbEFczK98hk/aa6HJxbl+UtLkJV2+Bvy5hLSLk3LHmqt0NTkKNso1A9y1a4w==",
"cpu": [
"x64"
],
@@ -1086,9 +1086,9 @@
}
},
"node_modules/@esbuild/sunos-x64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.2.tgz",
- "integrity": "sha512-cfZH1co2+imVdWCjd+D1gf9NjkchVhhdpgb1q5y6Hcv9TP6Zi9ZG/beI3ig8TvwT9lH9dlxLq5MQBBgwuj4xvA==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.3.tgz",
+ "integrity": "sha512-ROJhm7d8bk9dMCUZjkS8fgzsPAZEjtRJqCAmVgB0gMrvG7hfmPmz9k1rwO4jSiblFjYmNvbECL9uhaPzONMfgA==",
"cpu": [
"x64"
],
@@ -1104,9 +1104,9 @@
}
},
"node_modules/@esbuild/win32-arm64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.2.tgz",
- "integrity": "sha512-7Loyjh+D/Nx/sOTzV8vfbB3GJuHdOQyrOryFdZvPHLf42Tk9ivBU5Aedi7iyX+x6rbn2Mh68T4qq1SDqJBQO5Q==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.3.tgz",
+ "integrity": "sha512-YWcow8peiHpNBiIXHwaswPnAXLsLVygFwCB3A7Bh5jRkIBFWHGmNQ48AlX4xDvQNoMZlPYzjVOQDYEzWCqufMQ==",
"cpu": [
"arm64"
],
@@ -1122,9 +1122,9 @@
}
},
"node_modules/@esbuild/win32-ia32": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.2.tgz",
- "integrity": "sha512-WRJgsz9un0nqZJ4MfhabxaD9Ft8KioqU3JMinOTvobbX6MOSUigSBlogP8QB3uxpJDsFS6yN+3FDBdqE5lg9kg==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.3.tgz",
+ "integrity": "sha512-qspTZOIGoXVS4DpNqUYUs9UxVb04khS1Degaw/MnfMe7goQ3lTfQ13Vw4qY/Nj0979BGvMRpAYbs/BAxEvU8ew==",
"cpu": [
"ia32"
],
@@ -1140,9 +1140,9 @@
}
},
"node_modules/@esbuild/win32-x64": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.2.tgz",
- "integrity": "sha512-kM3HKb16VIXZyIeVrM1ygYmZBKybX8N4p754bw390wGO3Tf2j4L2/WYL+4suWujpgf6GBYs3jv7TyUivdd05JA==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.3.tgz",
+ "integrity": "sha512-ICgUR+kPimx0vvRzf+N/7L7tVSQeE3BYY+NhHRHXS1kBuPO7z2+7ea2HbhDyZdTephgvNvKrlDDKUexuCVBVvg==",
"cpu": [
"x64"
],
@@ -5576,9 +5576,9 @@
}
},
"node_modules/electron-to-chromium": {
- "version": "1.5.139",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.139.tgz",
- "integrity": "sha512-GGnRYOTdN5LYpwbIr0rwP/ZHOQSvAF6TG0LSzp28uCBb9JiXHJGmaaKw29qjNJc5bGnnp6kXJqRnGMQoELwi5w==",
+ "version": "1.5.141",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.141.tgz",
+ "integrity": "sha512-qS+qH9oqVYc1ooubTiB9l904WVyM6qNYxtOEEGReoZXw3xlqeYdFr5GclNzbkAufWgwWLEPoDi3d9MoRwwIjGw==",
"dev": true,
"license": "ISC"
},
@@ -5874,9 +5874,9 @@
}
},
"node_modules/es-module-lexer": {
- "version": "1.6.0",
- "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.6.0.tgz",
- "integrity": "sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ==",
+ "version": "1.7.0",
+ "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz",
+ "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==",
"dev": true,
"license": "MIT"
},
@@ -5941,9 +5941,9 @@
}
},
"node_modules/esbuild": {
- "version": "0.25.2",
- "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.2.tgz",
- "integrity": "sha512-16854zccKPnC+toMywC+uKNeYSv+/eXkevRAfwRD/G9Cleq66m8XFIrigkbvauLLlCfDL45Q2cWegSg53gGBnQ==",
+ "version": "0.25.3",
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.3.tgz",
+ "integrity": "sha512-qKA6Pvai73+M2FtftpNKRxJ78GIjmFXFxd/1DVBqGo/qNhLSfv+G12n9pNoWdytJC8U00TrViOwpjT0zgqQS8Q==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
@@ -5955,31 +5955,31 @@
"node": ">=18"
},
"optionalDependencies": {
- "@esbuild/aix-ppc64": "0.25.2",
- "@esbuild/android-arm": "0.25.2",
- "@esbuild/android-arm64": "0.25.2",
- "@esbuild/android-x64": "0.25.2",
- "@esbuild/darwin-arm64": "0.25.2",
- "@esbuild/darwin-x64": "0.25.2",
- "@esbuild/freebsd-arm64": "0.25.2",
- "@esbuild/freebsd-x64": "0.25.2",
- "@esbuild/linux-arm": "0.25.2",
- "@esbuild/linux-arm64": "0.25.2",
- "@esbuild/linux-ia32": "0.25.2",
- "@esbuild/linux-loong64": "0.25.2",
- "@esbuild/linux-mips64el": "0.25.2",
- "@esbuild/linux-ppc64": "0.25.2",
- "@esbuild/linux-riscv64": "0.25.2",
- "@esbuild/linux-s390x": "0.25.2",
- "@esbuild/linux-x64": "0.25.2",
- "@esbuild/netbsd-arm64": "0.25.2",
- "@esbuild/netbsd-x64": "0.25.2",
- "@esbuild/openbsd-arm64": "0.25.2",
- "@esbuild/openbsd-x64": "0.25.2",
- "@esbuild/sunos-x64": "0.25.2",
- "@esbuild/win32-arm64": "0.25.2",
- "@esbuild/win32-ia32": "0.25.2",
- "@esbuild/win32-x64": "0.25.2"
+ "@esbuild/aix-ppc64": "0.25.3",
+ "@esbuild/android-arm": "0.25.3",
+ "@esbuild/android-arm64": "0.25.3",
+ "@esbuild/android-x64": "0.25.3",
+ "@esbuild/darwin-arm64": "0.25.3",
+ "@esbuild/darwin-x64": "0.25.3",
+ "@esbuild/freebsd-arm64": "0.25.3",
+ "@esbuild/freebsd-x64": "0.25.3",
+ "@esbuild/linux-arm": "0.25.3",
+ "@esbuild/linux-arm64": "0.25.3",
+ "@esbuild/linux-ia32": "0.25.3",
+ "@esbuild/linux-loong64": "0.25.3",
+ "@esbuild/linux-mips64el": "0.25.3",
+ "@esbuild/linux-ppc64": "0.25.3",
+ "@esbuild/linux-riscv64": "0.25.3",
+ "@esbuild/linux-s390x": "0.25.3",
+ "@esbuild/linux-x64": "0.25.3",
+ "@esbuild/netbsd-arm64": "0.25.3",
+ "@esbuild/netbsd-x64": "0.25.3",
+ "@esbuild/openbsd-arm64": "0.25.3",
+ "@esbuild/openbsd-x64": "0.25.3",
+ "@esbuild/sunos-x64": "0.25.3",
+ "@esbuild/win32-arm64": "0.25.3",
+ "@esbuild/win32-ia32": "0.25.3",
+ "@esbuild/win32-x64": "0.25.3"
}
},
"node_modules/escalade": {
diff --git a/src/index.ts b/src/index.ts
index b73d81f..31adbe3 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -4,6 +4,10 @@ export type {
Options
} from './types'
+export {
+ getCallerSite
+} from './libs'
+
export {
main as stackTrace
}
diff --git a/src/libs/getCallerSite.ts b/src/libs/getCallerSite.ts
new file mode 100644
index 0000000..59c8fd0
--- /dev/null
+++ b/src/libs/getCallerSite.ts
@@ -0,0 +1,28 @@
+import main from '../main'
+
+/**
+ * Gets the caller's call site, starting after a specific callee.
+ *
+ * Returns the first call site from the current stack trace as a
+ * `NodeJS.CallSite`.
+ * If a callee is provided, the trace will start from the caller of the callee.
+ *
+ * @param {((...args: any) => any) | null} [callee] -
+ * Optional callee function or method to start tracing after.
+ * If `undefined` or `null`, tracing starts from the current caller.
+ *
+ * @returns {NodeJS.CallSite}
+ * A `NodeJS.CallSite` representing the first call site from the captured stack
+ * trace.
+ *
+ * @see https://github.com/mnrendra/stack-trace#readme
+ */
+const getCallerSite = (
+ callee?: ((...args: any) => any) | null
+): NodeJS.CallSite => {
+ const [callSite] = main(callee ?? getCallerSite, { limit: 1 })
+
+ return callSite
+}
+
+export default getCallerSite
diff --git a/src/libs/index.ts b/src/libs/index.ts
new file mode 100644
index 0000000..1269ccd
--- /dev/null
+++ b/src/libs/index.ts
@@ -0,0 +1,5 @@
+import getCallerSite from './getCallerSite'
+
+export {
+ getCallerSite
+}
diff --git a/src/main.ts b/src/main.ts
index 4bc5dae..657d946 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -3,22 +3,23 @@ import type { Options } from './types'
import { createTarget } from './utils'
/**
- * Traces the caller's call sites starting from a specific callee.
+ * Traces the caller's call sites, starting after a specific callee.
*
- * Captures the current stack trace as an array of `NodeJS.CallSite` objects. If
- * a callee is provided, the trace will start from the caller of the callee.
+ * Captures the current stack trace as an array of `NodeJS.CallSite`.
+ * If a callee is provided, the trace will start from the caller of the callee.
*
- * @param {((...args: any) => any) | null} [callee] - Optional callee function
- * or method to start tracing from. If `undefined` or `null`, tracing starts
- * from the current caller.
+ * @param {((...args: any) => any) | null} [callee] -
+ * Optional callee function or method to start tracing after.
+ * If `undefined` or `null`, tracing starts from the current caller.
*
- * @param {Options} [options] - Configuration options for tracing behavior. By
- * default, the `limit` option is set to `Infinity` to capture all frames. To
- * capture only a specific number of frames, set the `limit` option to a
+ * @param {Options} [options] -
+ * Configuration options for tracing behavior.
+ * By default, the `limit` option is set to `Infinity` to capture all frames.
+ * To capture only a specific number of frames, set the `limit` option to a
* positive number.
*
- * @returns {NodeJS.CallSite[]} An array of call sites representing the captured
- * stack trace.
+ * @returns {NodeJS.CallSite[]}
+ * An array of `NodeJS.CallSite` representing the captured stack trace.
*
* @see https://github.com/mnrendra/stack-trace#readme
*/