GithubHelp home page GithubHelp logo

capture-stack-trace's Introduction

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's People

Contributors

floatdrop avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

opichals okuyiga

capture-stack-trace's Issues

Missing License file in npm package

Hello, is it possible to incorporate the LICENSE file inside the npm package ? Now it's missing. It's implied by MIT license that if licensed under the MIT the source code must be accompanied by full license text. If the license file is not in the npm package a lot of people cannot use it.

Thank you

Yarn failed because the hash didn't match

error:
[1/4] Resolving packages...
[2/4] Fetching packages...
error http://registry.npm.taobao.org/capture-stack-trace/download/capture-stack-trace-1.0.1.tgz: Fetch succeeded for undefined. However, extracting "http://registry.npm.taobao.org/capture-stack-trace/download/capture-stack-trace-1.0.1.tgz" resulted in hash "a6c0bbe1f38f3aa0b92238ecb6ff42c344d4135d", which did not match the requested hash "ed0a1edb87c05d4db1037c5f8f483d8a3b5f0825".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

snip20180918_129
Hello, I found that the hash was changed but the version was not recently. So I should change the hash myself.

support `at` param

Error.captureStackTrace() supports an second param at/fn/subject

function a(fn) {
  const o = {}
  console.log(Error.captureStackTrace(o, fn))
}
function b(fn = a) { a(fn) }

function c() {
  // yields:
  // at b (...)
  // at c (...)
  b()

  // yields:
  // at c (...)
  b(b)
}

Ref on NodeJS (v8):
https://github.com/tapjs/stack-utils/blob/main/index.js#L142

It would be great if capture-stack-trace would support that too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.