You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@types/stack-utils

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/stack-utils

TypeScript definitions for stack-utils


Version published
Weekly downloads
19M
decreased by-19%
Maintainers
1
Install size
6.28 kB
Created
Weekly downloads
 

Package description

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

Readme

Source

Installation

npm install --save @types/stack-utils

Summary

This package contains type definitions for stack-utils (https://github.com/tapjs/stack-utils#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/stack-utils.

index.d.ts

export = StackUtils;

declare class StackUtils {
    static nodeInternals(): RegExp[];
    constructor(options?: StackUtils.Options);
    clean(stack: string | string[]): string;
    capture(limit?: number, startStackFunction?: Function): StackUtils.CallSite[];
    capture(startStackFunction: Function): StackUtils.CallSite[];
    captureString(limit?: number, startStackFunction?: Function): string;
    captureString(startStackFunction: Function): string;
    at(startStackFunction?: Function): StackUtils.CallSiteLike;
    parseLine(line: string): StackUtils.StackLineData | null;
}

declare namespace StackUtils {
    interface Options {
        internals?: RegExp[] | undefined;
        ignoredPackages?: string[] | undefined;
        cwd?: string | undefined;
        wrapCallSite?(callSite: CallSite): CallSite;
    }

    interface CallSite {
        getThis(): object | undefined;
        getTypeName(): string;
        getFunction(): Function | undefined;
        getFunctionName(): string;
        getMethodName(): string | null;
        getFileName(): string | undefined;
        getLineNumber(): number;
        getColumnNumber(): number;
        getEvalOrigin(): CallSite | string;
        isToplevel(): boolean;
        isEval(): boolean;
        isNative(): boolean;
        isConstructor(): boolean;
    }

    interface CallSiteLike extends StackData {
        type?: string | undefined;
    }

    interface StackLineData extends StackData {
        evalLine?: number | undefined;
        evalColumn?: number | undefined;
        evalFile?: string | undefined;
    }

    interface StackData {
        line?: number | undefined;
        column?: number | undefined;
        file?: string | undefined;
        constructor?: boolean | undefined;
        evalOrigin?: string | undefined;
        native?: boolean | undefined;
        function?: string | undefined;
        method?: string | undefined;
    }
}

Additional Details

  • Last updated: Tue, 07 Nov 2023 15:11:36 GMT
  • Dependencies: none

Credits

These definitions were written by BendingBender.

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc