npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

stackinfo

v1.1.5

Published

Gets an object containing normalized stacktrace information across browsers.

Downloads

435

Readme

stackinfo

Gets an object containing normalized stacktrace information across browsers. If you want to programmatically inspect the stack, this is the module for you. This uses stacktrace.js to get stack traces.

Example

var info = stackinfo()
console.log('This is line '+(info[0].line + 1))

Install

npm install stackinfo

Usage

var stackinfo = require('stackinfo') // common js

require('node_modules/generatedBuild/stackinfo.umd.js', function(stackinfo) {/*...*/}) // require.js
<script src="node_modules/generatedBuild/stackinfo.umd.js"></script> <!-- browser global -->

stackinfo([<exception>]) - returns stack trace information in the below format. If <exception> is passed, the stacktrace will be taken from that exception, otherwise a stacktrace will be generated for the current call. Passed exceptions doesn't work in IE or Safari 5 (this is a limitation of stacktrace.js).

##Format##

The stacktrace information is returned as a list of objects that each have getter properties that parse the stacktrace line (and cache the result). The properties are:

  • function - the name of the function that was running in the particular stack frame
  • file - the file-path of the file in which the function was running
  • line - the line number
  • column - the column number
  • info - an object containing the above 4 properties

Any of these properties may be undefined if they are unavailable.

Browser Support

Tested in the following browsers:

  • Chrome 31
  • Firefox 26
  • IE 10

Note that stackinfo doesn't work in node.js, but if you need that, check out node-stack-trace

Todo

  • When firefox adds column numbers into its stack traces, add those to stack info
  • Test more browsers
  • Particularly latest version of Opera, Opera mini, Android mobile, Safari, and Safari iOS
  • Create unit tests once deadunit supports browser
  • Support node.js via node-stack-trace
  • Possibly also use this for chrome, since it works in chrome too

How to Contribute!

Anything helps:

  • Creating issues (aka tickets/bugs/etc). Please feel free to use issues to report bugs, request features, and discuss changes.
  • Updating the documentation: ie this readme file. Be bold! Help create amazing documentation!
  • Submitting pull requests.

How to submit pull requests:

  1. Please create an issue and get my input before spending too much time creating a feature. Work with me to ensure your feature or addition is optimal and fits with the purpose of the project.
  2. Fork the repository
  3. clone your forked repo onto your machine and run npm install at its root
  4. If you're gonna work on multiple separate things, its best to create a separate branch for each of them
  5. edit!
  6. If it's a code change, please add to the test file (at test/testStackinfo.js) to verify that your change works
  7. When you're done, run the unit tests and ensure they all pass
  8. Commit and push your changes
  9. Submit a pull request: https://help.github.com/articles/creating-a-pull-request

Change Log

  • 1.1.4 - fixing chrome traceline where function-part contains a number by itself between dots
  • 1.1.3 - upgrading tests to use deadunit and supporting new firefox stacklines that have columns now!
  • 1.1.2 - Working around this stacktrace.js bug for ie 10: https://github.com/stacktracejs/stacktrace.js/issues/80
  • 1.1.1 - outputting line and column numbers as Numbers instead of as Strings.
  • 1.0.9 - fixing bug where the wrong stacktrace would be returned when one was passed in
  • 1.0.6 - exposing stacktrace.js's sourceCache so it can be consolidated with source caches from other modules
  • 1.0.4 - adding a firefox trace pattern
  • 1.0.3 - adding another chrome trace pattern (event handlers)
  • 1.0.2
    • adding a couple chrome trace patterns that previously didn't parse
  • 1.0.0
    • BREAKING CHANGE
    • For performance reasons, a stackinfo element no longer parses the stacktrace upfront, instead it parses it once the function, file, line, or column are asked for.
    • This means that looping through the element will no longer give you the properties - you have to access them via their getters
  • 0.0.4
    • adding getSource error regex for ie and firefox
  • 0.0.3
    • adding regex for parsing stacktrace.js getSource error, which makes it so the file and line number can still be reported even if the function name can't be guessed
  • 0.0.2
    • fixing incorrect regex which caused major performance issues
  • 0.0.1
    • Initial release - supports latest versions of chrome, firefox, and ie

License

Released under the MIT license: http://opensource.org/licenses/MIT