🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

@types/stack-utils

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/stack-utils

TypeScript definitions for stack-utils

2.0.3
ts4.5
ts4.6
ts4.7
ts4.8
ts4.9
ts5.0
ts5.1
ts5.2
ts5.3
ts5.4
ts5.5
ts5.6
ts5.7
ts5.8
ts5.9
latest
Version published
Weekly downloads
33M
2.96%
Maintainers
1
Weekly downloads
 
Created

What is @types/stack-utils?

@types/stack-utils provides TypeScript type definitions for the stack-utils library, which is used for parsing and manipulating stack traces in JavaScript. This can be particularly useful for debugging and error handling.

What are @types/stack-utils's main functionalities?

Parsing Stack Traces

This feature allows you to parse a stack trace into a more readable and structured format. The code sample demonstrates how to create a StackUtils instance and parse the stack trace of a new Error.

const StackUtils = require('stack-utils');
const stack = new StackUtils({ cwd: process.cwd(), internals: StackUtils.nodeInternals() });
const parsedStack = stack.parse(new Error().stack);
console.log(parsedStack);

Cleaning Stack Traces

This feature allows you to clean a stack trace by removing internal Node.js entries and other noise. The code sample shows how to clean the stack trace of a new Error.

const StackUtils = require('stack-utils');
const stack = new StackUtils({ cwd: process.cwd(), internals: StackUtils.nodeInternals() });
const cleanedStack = stack.clean(new Error().stack);
console.log(cleanedStack);

Customizing Stack Trace Output

This feature allows you to customize the output format of stack traces. The code sample demonstrates how to wrap call sites to format the stack trace entries in a custom way.

const StackUtils = require('stack-utils');
const stack = new StackUtils({ cwd: process.cwd(), internals: StackUtils.nodeInternals(), wrapCallSite: (callSite) => ({
  getFileName: () => callSite.getFileName(),
  getLineNumber: () => callSite.getLineNumber(),
  getColumnNumber: () => callSite.getColumnNumber(),
  toString: () => `${callSite.getFileName()}:${callSite.getLineNumber()}:${callSite.getColumnNumber()}`
}) });
const customStack = stack.clean(new Error().stack);
console.log(customStack);

Other packages similar to @types/stack-utils

FAQs

Package last updated on 07 Nov 2023

Did you know?

Socket

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