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

line-stack

v0.1.2

Published

Get current line stack information such as line number, method, file, filename, callSites, and more. Can search through callSites for/skip a particular functionName, typeName, or filename.

Downloads

7

Readme

line-stack

npm npm

Get current line stack information such as line number, method, file, filename, callSites, and more. Can search through callSites for/skip a particular functionName, typeName, or filename.

Typedefs

lineStack

Example

const lineStack = require('line-stack')

LineStack ⏏

Kind: Exported class

lineStack.get([level]) ⇒ StackItem

Returns stack trace which can be console logged

lineStack.get([level]) ⇒ StackItem

Returns a single item at given level

Kind: instance method of LineStack

| Param | Type | Default | Description | |---------|----------|-----------|---------------------------------------------------------------------------------------------------------------------------| | [level] | number | 0 | Useful to return levels up on the stack. If not informed, the first (0, zero index) element of the stack will be returned |

lineStack.findByFilename(rx, fromIndex, stack, returnIndex) ⇒ StackItem | number | void

find the stack using filename that matches the given RegExp or string.

Kind: instance method of LineStack

| Param | Type | Default | Description | |-------------|---------------------------------------|----------|-----------------------------------------------------------------| | rx | string \ RegExp | | string or regular expression to use to find the item | | fromIndex | number | 0 | the index of the first item to find | | stack | Array.<CallSite> | | array of StackItems to search through | | returnIndex | boolean | false | if true, return the stack index the item is instead of the item |

lineStack.skipByFilename(matcher) ⇒ StackItem | void

find the next stack using filename that doesn't match the given string.

Kind: instance method of LineStack

| Param | Type | |---------|----------| | matcher | string |

lineStack.findByTypeName(rx, fromIndex, stack, returnIndex) ⇒ StackItem | number | void

find the stack using type name that matches the given RegExp or string.

Kind: instance method of LineStack

| Param | Type | Default | Description | |-------------|---------------------------------------|----------|-----------------------------------------------------------------| | rx | string \ RegExp | | string or regular expression to use to find the item | | fromIndex | number | 0 | the index of the first item to find | | stack | Array.<CallSite> | | array of StackItems to search through | | returnIndex | boolean | false | if true, return the stack index the item is instead of the item |

lineStack.skipByTypeName(matcher) ⇒ StackItem | void

find the next stack using type name that doesn't match the given string.

Kind: instance method of LineStack

| Param | Type | |---------|----------| | matcher | string |

lineStack.findByFunctionName(rx, fromIndex, stack, returnIndex) ⇒ StackItem | number | void

find the stack using function name that matches the given RegExp or string.

Kind: instance method of LineStack

| Param | Type | Default | Description | |-------------|---------------------------------------|-----------|-----------------------------------------------------------------| | rx | string \ RegExp | | string or regular expression to use to find the item | | fromIndex | number | 0 | the index of the first item to find | | stack | Array.<CallSite> | | array of StackItems to search through | | returnIndex | boolean | false | if true, return the stack index the item is instead of the item |

lineStack.skipByFunctionName(matcher) ⇒ StackItem | void

find the next stack using function name that doesn't match the given string.

Kind: instance method of LineStack

| Param | Type | |---------|-----------| | matcher | string |

lineStack.all() ⇒ Array.<CallSite>

Returns all stack

Kind: instance method of LineStack

lineStack.parseCallSitesToStack(Array.<CallSite>) ⇒ String

Returns stack trace based off given callSites

Kind: instance method of LineStack

LineStack~getStack() ⇒ Array.<CallSite>

Get the call callSites stack

Kind: inner method of LineStack

LineStack~parse(item, stack) ⇒ StackItem

Parse the given stack item

Kind: inner method of LineStack

| Param | |---------| | item | | stack |

LineStack~iterateStack(stack, fromIndex, returnIndex, predicate) ⇒ StackItem | number | void

iterate through given stack items and return of first item where predicate returns truthy.

Kind: inner method of LineStack

| Param | Type | Description | |-------------|---------------------------------------|----------------------------------------------------------------------------------| | stack | Array.<CallSite> | stack to iterate through | | fromIndex | number | the index to start at | | returnIndex | boolean | if true, return the stack index the item is instead of the item | | predicate | function | predicate function to use. called with arguments (item) - the current stack item |

CallSite : object

Kind: global typedef
Properties

| Name | Type | |-------------------|-------------------------------------| | getThis() | object or undefined | | getTypeName() | string | | getFunction() | function or undefined | | getFunctionName() | string | | getMethodName() | string or null | | getFileName() | string or undefined | | getLineNumber() | number | | getColumnNumber() | number | | getEvalOrigin() | CallSite or string | | isToplevel() | boolean | | isEval() | boolean | | isNative() | boolean | | isConstructor() | boolean |

StackItem : object

Kind: global typedef
Properties

| Name | Type | Description | |-----------|---------------------------------------|---------------------------------------| | method | string | Name of function on stack | | line | number | Line number on stack | | file | string | /PathOfFile/Source/NameOfFilename.js | | filename | string | NameOfFile | | callSites | Array.<CallSite> | /PathOfFile/Source/NameOfFilename.js |

Author

Emmanuel Mahuni