Socket
Socket
Sign inDemoInstall

stackback

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

stackback

return list of CallSite objects from a captured stacktrace


Version published
Maintainers
1
Weekly downloads
3,511,251
decreased by-7.12%

Weekly downloads

Package description

What is stackback?

The stackback npm package is designed to provide an easy way to extract a stack trace from a given Error object. It parses the stack property of Error objects to return an array of call site objects, which can be used for debugging or logging purposes. This can be particularly useful in environments where understanding the sequence of function calls leading to an error is crucial for diagnosing issues.

What are stackback's main functionalities?

Extracting stack traces from Error objects

This feature allows developers to pass an Error object to the stackback function, which returns an array of call site objects representing the stack trace. Each call site object provides detailed information about each stack frame, such as the file name, line number, and column number where the error occurred. This can be invaluable for debugging by providing a clear path of execution up to the point where the error was thrown.

const stackback = require('stackback');
const error = new Error('Test Error');
const stack = stackback(error);
console.log(stack);

Other packages similar to stackback

Readme

Source

stackback

Returns an array of CallSite objects for a captured stacktrace. Useful if you want to access the frame for an error object.

use

var stackback = require('stackback');

// error generated from somewhere
var err = new Error('some sample error');

// stack is an array of CallSite objects
var stack = stackback(err);

CallSite object

From the V8 StackTrace API

The structured stack trace is an Array of CallSite objects, each of which represents a stack frame. A CallSite object defines the following methods

getThis: returns the value of this
getTypeName: returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property.
getFunction: returns the current function
getFunctionName: returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context.
getMethodName: returns the name of the property of this or one of its prototypes that holds the current function
getFileName: if this function was defined in a script returns the name of the script
getLineNumber: if this function was defined in a script returns the current line number
getColumnNumber: if this function was defined in a script returns the current column number
getEvalOrigin: if this function was created using a call to eval returns a CallSite object representing the location where eval was called
isToplevel: is this a toplevel invocation, that is, is this the global object?
isEval: does this call take place in code defined by a call to eval?
isNative: is this call in native V8 code?
isConstructor: is this a constructor call?

install

npm install stackback

Keywords

FAQs

Last updated on 20 Oct 2012

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc