stack-patcher
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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";

Package Sidebar

Install

npm i stack-patcher

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

4.8 kB

Total Files

6

Last publish

Collaborators

  • alexxandergrib