-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
- Loading branch information
1 parent
467c1de
commit 5bb4f50
Showing
1 changed file
with
13 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |