0.1.2 • Published 2 years ago

line-stack v0.1.2

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
2 years ago

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

ParamTypeDefaultDescription
levelnumber0Useful 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

ParamTypeDefaultDescription
rxstring \ RegExpstring or regular expression to use to find the item
fromIndexnumber0the index of the first item to find
stackArray.<CallSite>array of StackItems to search through
returnIndexbooleanfalseif 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

ParamType
matcherstring

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

ParamTypeDefaultDescription
rxstring \ RegExpstring or regular expression to use to find the item
fromIndexnumber0the index of the first item to find
stackArray.<CallSite>array of StackItems to search through
returnIndexbooleanfalseif 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

ParamType
matcherstring

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

ParamTypeDefaultDescription
rxstring \ RegExpstring or regular expression to use to find the item
fromIndexnumber0the index of the first item to find
stackArray.<CallSite>array of StackItems to search through
returnIndexbooleanfalseif 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

ParamType
matcherstring

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

ParamTypeDescription
stackArray.<CallSite>stack to iterate through
fromIndexnumberthe index to start at
returnIndexbooleanif true, return the stack index the item is instead of the item
predicatefunctionpredicate function to use. called with arguments (item) - the current stack item

CallSite : object

Kind: global typedef
Properties

NameType
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

NameTypeDescription
methodstringName of function on stack
linenumberLine number on stack
filestring/PathOfFile/Source/NameOfFilename.js
filenamestringNameOfFile
callSitesArray.<CallSite>/PathOfFile/Source/NameOfFilename.js

Author

Emmanuel Mahuni