[DEPRECATED]
This project has been deprecated in favor of tusk.js.
The deprecation is due to initial structural decisions that led to issues such as incorrect versioning (starting at 1.0.1
), which caused problems with the GitHub CLI publishing flow.
Additionally, the lack of branching and committing directly to main
made the history unclear and hard to maintain.
Please refer to tusk.js for future updates and improvements.
Tusk
👉 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");
unpatch(logger, "log");
logger.log("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:
npm install tusk
pnpm add tusk
yarn add tusk
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.
-
Is Tusk compatible with all JavaScript runtimes?
Yes, Tusk works seamlessly with Node.js, Bun, and Deno.
Made with ❤️ by ofabiodev. Happy coding! 🚀