Skip to content

Commit

Permalink
Add support for Bun (#20)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
  • Loading branch information
BenBeattieHood and sindresorhus authored Aug 12, 2023
1 parent 467c1de commit 5bb4f50
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
export default function callsites() {
const _prepareStackTrace = Error.prepareStackTrace;
Error.prepareStackTrace = (_, stack) => stack;
const stack = new Error().stack.slice(1); // eslint-disable-line unicorn/error-message
Error.prepareStackTrace = _prepareStackTrace;
return stack;
try {
let result = [];
Error.prepareStackTrace = (_, callSites) => {
const callSitesWithoutCurrent = callSites.slice(1);
result = callSitesWithoutCurrent;
return callSitesWithoutCurrent;
};

new Error().stack; // eslint-disable-line unicorn/error-message, no-unused-expressions
return result;
} finally {
Error.prepareStackTrace = _prepareStackTrace;
}
}

0 comments on commit 5bb4f50

Please sign in to comment.