@cjser/capture-stack-trace
v2.1.0-cjser.2
Published
Error.captureStackTrace ponyfill
Downloads
79
Maintainers
Readme
capture-stack-trace
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-traceUsage
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.
cjser
This package is a CommonJS-compatible build generated by cjser for projects that still need require() support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.
Original repository: https://github.com/sindresorhus/capture-stack-trace
