Skip to content

Commit 5bb4f50

Browse files
BenBeattieHoodsindresorhus
andauthoredAug 12, 2023
Add support for Bun (#20)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
1 parent 467c1de commit 5bb4f50

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed
 

Diff for: ‎index.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
export default function callsites() {
22
const _prepareStackTrace = Error.prepareStackTrace;
3-
Error.prepareStackTrace = (_, stack) => stack;
4-
const stack = new Error().stack.slice(1); // eslint-disable-line unicorn/error-message
5-
Error.prepareStackTrace = _prepareStackTrace;
6-
return stack;
3+
try {
4+
let result = [];
5+
Error.prepareStackTrace = (_, callSites) => {
6+
const callSitesWithoutCurrent = callSites.slice(1);
7+
result = callSitesWithoutCurrent;
8+
return callSitesWithoutCurrent;
9+
};
10+
11+
new Error().stack; // eslint-disable-line unicorn/error-message, no-unused-expressions
12+
return result;
13+
} finally {
14+
Error.prepareStackTrace = _prepareStackTrace;
15+
}
716
}

0 commit comments

Comments
 (0)
Please sign in to comment.