8000 GitHub - sindresorhus/capture-stack-trace: Ponyfill for Error#captureStackTrace
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

sindresorhus/capture-stack-trace

Repository files navigation

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.

About

Ponyfill for Error#captureStackTrace

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0