# capture-stack-trace

> Error.captureStackTrace ponyfill

Latest version **2.1.0** (published 2022-10-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install capture-stack-trace
pnpm add capture-stack-trace
yarn add capture-stack-trace
bun add capture-stack-trace
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2022-10-10 |
| First published | 2015-07-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=14.16 |
| Dependencies | 0 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 62 |
| Maintainers | sindresorhus |
| Keywords | ponyfill, polyfill, shim, error, capturestacktrace, capture, stack, trace |

## Links

- npm: https://www.npmjs.com/package/capture-stack-trace
- Repository: https://github.com/sindresorhus/capture-stack-trace
- Homepage: https://github.com/sindresorhus/capture-stack-trace#readme
- Issues: https://github.com/sindresorhus/capture-stack-trace/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/capture-stack-trace

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 2.1.0 (latest) — 2022-10-10
- 2.0.0 — 2022-10-07
- 1.0.2 — 2022-10-07
- 1.0.1 — 2018-08-31
- 1.0.0 — 2015-07-24

## 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`.

---
_Source: https://npm.io/package/capture-stack-trace · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
