capture-stack-trace
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

capture-stack-trace

Ponyfill for Error#captureStackTrace

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

npm install capture-stack-trace

Usage

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.

/capture-stack-trace/

    Package Sidebar

    Install

    npm i capture-stack-trace

    Weekly Downloads

    1,614,700

    Version

    2.1.0

    License

    MIT

    Unpacked Size

    3.53 kB

    Total Files

    5

    Last publish

    Collaborators

    • sindresorhus