You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lightweight [stack trace](https://v8.dev/docs/stack-trace-api) utility to retrieve `CallSite` objects from a specific caller.
8
12
9
-
A lightweight [stack trace](https://v8.dev/docs/stack-trace-api) utility to retrieve `CallSite` objects from a specific caller.<br/>
10
13
*Useful for debugging, logging, or building tools that need to trace call origins at runtime.*
11
14
15
+
## Features
16
+
- ✅ Supports both **ES Modules** and **CommonJS** from a single source - see [package](https://www.npmjs.com/package/@mnrendra/stack-trace?activeTab=code)
17
+
- ✅ Minified and cleansed of unnecessary dependencies, files, and attributes - see [contents](https://www.npmjs.com/package/@mnrendra/stack-trace?activeTab=code)
18
+
- ✅ Tiny package - see [size](https://bundlephobia.com/package/@mnrendra/stack-trace)
19
+
- ✅ Well tested - see [coverage](https://app.codecov.io/gh/mnrendra/stack-trace)
20
+
- ✅ Verified all commits - see [signatures](https://github.com/mnrendra/stack-trace/commits/main)
21
+
- ✅ Semantic versioning - see [commits](https://github.com/mnrendra/stack-trace/commits/main)
22
+
- ✅ Actively maintained - [pull requests](https://github.com/mnrendra/stack-trace/pulls), [issues](https://github.com/mnrendra/stack-trace/issues), and [discussions](https://github.com/mnrendra/stack-trace/discussions) are welcome!
23
+
12
24
## Install
13
25
```bash
14
26
npm i @mnrendra/stack-trace
@@ -129,26 +141,26 @@ If the extracted file name is not a string or not absolute.
129
141
130
142
## Usage
131
143
132
-
### CommonJS
133
-
`/foo/callee.cjs`
144
+
### ES Modules
145
+
`/foo/callee.mjs`
134
146
```javascript
135
-
const { dirname } =require('node:path')
147
+
import { dirname } from'node:path'
136
148
137
-
const {
149
+
import {
138
150
stackTrace,
139
151
getCallerSite,
140
152
extractFilePath,
141
153
getCallerFile,
142
154
getCallerDir
143
-
} =require('@mnrendra/stack-trace')
155
+
} from'@mnrendra/stack-trace'
144
156
145
157
constcallee= () => {
146
158
// `stackTrace`:
147
159
const [callSite1] =stackTrace()
148
160
const [callSite2] =stackTrace(callee, { limit:1 }) // Pass the `callee` function as the callee.
0 commit comments