Skip to content

Releases: ofabiodev/tusk

1.0.1 (2025-03-01)

01 Mar 12:54
Compare
Choose a tag to compare

Tusk

Tusk

NPM Version NPM Downloads

👉 Read the Docs

Ever felt frustrated with the limitations of modifying object behavior in JavaScript/TypeScript? Or maybe you're tired of writing repetitive code for debugging and testing? Tusk is here to solve these problems with its powerful and flexible runtime object manipulation tools!

⚙️ Getting Started
To start using Tusk, simply install it via npm, yarn, or Bun. Then, you can begin extending objects or patching methods in seconds. More on this later.

Tusk allows you to temporarily modify existing methods while keeping the original behavior intact. It's perfect for debugging, testing, or enhancing functionality without touching the original codebase.

👀 Psst...
With Tusk, you can even restore the original behavior of patched methods with a single command. It's as easy as it gets!

Monkey Patching

import { patch, unpatch } from "tusk";

const logger = {
  log: (msg: string) => console.log(msg),
};

patch(logger, "log", (original, msg) => {
  original(`[Tusk]: ${msg}`);
});

logger.log("This is a test"); // [Tusk]: This is a test

unpatch(logger, "log");
logger.log("This is a test"); // This is a test

Controlled Monkey Patching allows you to temporarily modify existing methods, with the ability to restore the original behavior at any time. This is perfect for debugging, testing, or adding runtime enhancements.

To patch a method, use patch. When you're done, simply call unpatch to revert to the original behavior. It's that easy!

💡 Good-To-Know
Monkey Patching is powerful but should be used sparingly. Always document your patches to avoid confusion.


Installation 📦

To install Tusk, run one of the following commands:

# Using npm
npm install tusk

# Using pnpm
pnpm add tusk

# Using yarn
yarn add tusk

# Using Bun
bun add tusk

F.A.Q. 🤔

  • Can I use Tusk in production?
    Yes, but it's primarily designed for debugging, testing, and development.

  • Does Tusk work with async functions?
    Absolutely! Tusk supports both synchronous and asynchronous functions.


Made with ❤️ by ofabiodev. Happy coding! 🚀