Skip to content

AlexXanderGrib/stack-patcher

Repository files navigation

Stack Patcher

4KB package wraps any function in function with your custom name to help you catch bugs in error stacktraces

ExampleSource FileRepoWhy??? [RU]

  • Small. Weighs only 4KB;
  • Fast and Secure. Uses JS-native approach of renaming functions instead of eval;
  • Simple. You can just copy source to your project, i wan't be mad.
  • Cross-Platform. Works in node and browser

Example

import { wrapCall } from "stack-patcher";

const call = wrapCall("username=AlexXanderGrib", () => {
  throw new Error();
});

call.async()
  .catch((error) => console.log(error.stack));
// Error
//   at example.ts:4:4
//   at username=AlexXanderGrib
//      ^^^^^^^^^^^^^^^^^^^^^^^

Installation

  • Using npm
    npm i stack-patcher
  • Using Yarn
    yarn add stack-patcher
  • Using pnpm
    pnpm add stack-patcher

Import

  • CommonJS (default for Node JS)

    const { wrapCall } = require("stack-patcher");
  • TypeScript or ES Modules

    import { wrapCall } from "stack-patcher";

About

Package wraps any function in function with your custom name to help you catch bugs in error stacktraces

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published