diff --git a/index.js b/index.js index 7778f35..513c6fd 100644 --- a/index.js +++ b/index.js @@ -1,16 +1,7 @@ export default function callsites() { const _prepareStackTrace = Error.prepareStackTrace; - 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; - } + Error.prepareStackTrace = (_, stack) => stack; + const stack = new Error().stack.slice(1); // eslint-disable-line unicorn/error-message + Error.prepareStackTrace = _prepareStackTrace; + return stack; }