@ludeschersoftware/ticktock
v1.0.1
Published
A lightweight utility for delaying function execution with ease. TickTock wraps your callback and ensures it only runs after a pause, perfect for debouncing rapid events like keystrokes, window resizing, or API calls. Simple, effective, and ready to run.
Readme
⏳ TickTock
A lightweight utility for delaying function execution with ease.
TickTock wraps your callback and ensures it only runs after a pause, perfect for debouncing rapid events like keystrokes, window resizing, or API calls. Simple, effective, and ready to run.
🚀 Installation
npm install @ludeschersoftware/ticktockor
yarn add @ludeschersoftware/ticktock📦 Usage
import TickTock from "@ludeschersoftware/ticktock";
const debouncedLog = new TickTock((msg: string) => {
console.log("Debounced:", msg);
}, 1000); // Delay in milliseconds
debouncedLog.run("Hello");
debouncedLog.run("Hello again"); // Only this will be logged after 1 second🧠 API
new TickTock(callback: (...args: any[]) => void, delay?: number)
callback: Function to execute after the delaydelay: Optional delay in milliseconds (default:500)
.run(...args: any[])
- Triggers the debounced execution of the callback with the provided arguments.
🛠️ Development
npm run build # Compile TypeScript
npm run watch # Watch for changes📄 License
MIT © Johannes Ludescher
🐛 Issues
Found a bug or have a feature request? Open an issue
