# capture-stack-trace **Repository Path**: mirrors_sindresorhus/capture-stack-trace ## Basic Information - **Project Name**: capture-stack-trace - **Description**: Ponyfill for Error#captureStackTrace - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-10-24 - **Last Updated**: 2026-05-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # capture-stack-trace > [Ponyfill](https://ponyfill.com) for [`Error#captureStackTrace`](https://nodejs.org/api/errors.html#errorcapturestacktracetargetobject-constructoropt) This is useful for creating cross-platform code as `Error#captureStackTrace` is only available in V8-based JavaScript environments like Node.js and Chrome. ## Install ```sh npm install capture-stack-trace ``` ## Usage ```js import captureStackTrace from 'capture-stack-trace'; const object = {}; captureStackTrace(object); object.stack; // Similar to `new Error().stack` ``` ## API ### captureStackTrace(object) Creates a `.stack` property on the given `object`, which when accessed returns a string representing the location in the code at which `captureStackTrace()` was called. **Note:** This ponyfill does not support the second parameter of `Error#captureStackTrace`.