{"id":"krazeems/ratemanager","name":"ratemanager","scope":"krazeems","platform":"roblox","description":"Roblox Lua utility for debounce and rate limiting with bundled Signal.","version":"1.0.0","latest":"1.0.0","versions":["1.0.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"07df7485ff1086725da0ec50c9d32fb3c6323e48eeff17f26e3f2d42f474477d","likes":0,"downloads":0,"install":"forest install krazeems/ratemanager","url":"https://forest.dev/p/roblox/krazeems/ratemanager","files":"https://api.forest.dev/ai/package/roblox/krazeems/ratemanager/files","readme":"<h1 align=\"center\">🔁 RateManager</h1>\n<p align=\"center\">\n  A lightweight utility for handling <strong>cooldowns</strong> and <strong>rate limits</strong> in Roblox Lua.\n</p>\n<p align=\"center\">\n  Debounce, rolling limits, queueing, pause/resume, and more: all in one clean module.\n</p>\n\n---\n\n## 🚀 Features\n\n- ⏱️ Debounce (classic cooldown)  \n- 🔁 RateLimit (e.g. 10 calls per 60 seconds)  \n- 🧱 Optional call queueing (RateLimit only)  \n- ⏸️ Pause & Resume  \n- 🔄 Manual `Reset()` and `Cancel()` (with queue control)  \n- 🔔 Signals: `OnReset`, `OnLimitHit`  \n- 📦 Self-contained, no external dependencies  \n- 🧼 MIT licensed  \n\n---\n\n## 📦 Installation\n\n<details>\n  <summary><strong>Manual</strong></summary>\n\n1. Drop `RateManager.lua` into your project (e.g. `ReplicatedStorage.Packages`)  \n2. Require it in your scripts:\n\n```lua\nlocal RateManager = require(game.ReplicatedStorage.Packages.RateManager)\n````\n\n</details>\n\n<details>\n  <summary><strong>Wally (Recommended)</strong></summary>\n\nAdd RateManager as a dependency in your `wally.toml`:\n\n```toml\n[dependencies]\nratemanager = \"krazeems/ratemanager@1.0.0\"\n```\n\nThen run in your terminal:\n\n```bash\nwally install\n```\n\nThis downloads RateManager (including bundled Signal) to your `wally_modules` folder.\n\n</details>\n\n<details>\n  <summary><strong>Rojo</strong></summary>\n\nMake sure your `default.project.json` (or `.rojo.json`) includes RateManager so Rojo syncs it to Roblox:\n\n```json\n{\n  \"name\": \"MyProject\",\n  \"tree\": {\n    \"$className\": \"Folder\",\n    \"ReplicatedStorage\": {\n      \"$className\": \"Folder\",\n      \"RateManager\": {\n        \"$path\": \"wally_modules/krazeems/ratemanager/RateManager\"\n      }\n    }\n  }\n}\n```\n\nAdjust the `$path` if you use manual installation or a different directory.\n\n</details>\n\n<details>\n  <summary><strong>Require in your code</strong></summary>\n\n```lua\nlocal RateManager = require(game:GetService(\"ReplicatedStorage\"):WaitForChild(\"RateManager\"))\n```\n\n</details>\n\n---\n\n## 🔨 Example Usage\n\n### 🕒 Debounce (Cooldown that ignores spam)\n\n```lua\nlocal cooldown = RateManager.new(2) -- 2 second cooldown\n\nbutton.MouseButton1Click:Connect(function()\n\tcooldown:Execute(function()\n\t\tprint(\"Clicked!\") -- Fires once every 2 seconds max\n\tend)\nend)\n```\n\n---\n\n### 🔁 RateLimit (e.g. 5 calls per 10 seconds)\n\n```lua\nlocal limiter = RateManager.new(5, 10, RateManager.Mode.RateLimit)\n\nRunService.Heartbeat:Connect(function()\n\tlimiter:Execute(function()\n\t\tprint(\"Allowed!\")\n\tend)\nend)\n```\n\n---\n\n### 🧱 Queueing (for RateLimit)\n\n```lua\nlimiter:SetQueueEnabled(true)\n```\n\n> Excess calls will be queued instead of dropped\n\n---\n\n### ⏸️ Pause / Resume\n\n```lua\nlimiter:Pause()\nwait(5)\nlimiter:Resume()\n```\n\n---\n\n### ⚠️ Reset vs Cancel\n\n```lua\ncooldown:Reset()      -- Ends timer and fires OnReset\ncooldown:Cancel()     -- Ends timer silently\n\ncooldown:Reset(true)  -- Ends and clears queued calls (RateLimit only)\ncooldown:Cancel(true) -- Cancels and clears queue (no OnReset)\n```\n\n---\n\n### 🔔 Events\n\n```lua\ncooldown.OnReset:Connect(function()\n\tprint(\"Cooldown/rate limit reset!\")\nend)\n\ncooldown.OnLimitHit:Connect(function()\n\tprint(\"Call was blocked (cooldown active or limit hit)\")\nend)\n```\n\n---\n\n## 📚 API\n\n```lua\nRateManager.new(delayOrMaxCalls: number, perSeconds?: number, mode?: RateManager.Mode) → RateManager\n```\n\n| Method                            | Description                                   |\n| --------------------------------- | --------------------------------------------- |\n| `:Execute(func, ...)`             | Executes the callback if allowed              |\n| `:Reset(dropQueuedCalls?)`        | Ends cooldown/rate window and fires `OnReset` |\n| `:Cancel(dropQueuedCalls?)`       | Ends it silently, skips `OnReset`             |\n| `:Pause()` / `:Resume()`          | Temporarily pause/resume timer logic          |\n| `:IsOnCooldown()`                 | Returns true if currently blocked             |\n| `:GetTimeLeft()`                  | Returns remaining cooldown time (in seconds)  |\n| `:SetQueueEnabled(enabled: bool)` | Enables queueing (RateLimit mode only)        |\n| `:Destroy()`                      | Cleans up signals and state                   |\n\n| Event        | Description                              |\n| ------------ | ---------------------------------------- |\n| `OnReset`    | Fires when timer or rate window is reset |\n| `OnLimitHit` | Fires when a call is blocked by cooldown |\n\n---\n\n## 📎 Links\n\n* 🔗 [Creator Store](https://create.roblox.com/store/asset/110870034905030/RateManager)\n* 🧵 [DevForum Post](https://devforum.roblox.com/t/new-ratemanager-cooldown-rate-limiting-utility-debounce-rolling-limit-queued-calls-pause-resume/3803316)\n\n---\n\n## 🧩 Final Notes\n\nRateManager was built to simplify cooldown and rate-limiting logic in Roblox without bloating your code. It’s clean, event-based, and flexible for nearly any input-related system.\n\nSuggestions and contributions are always welcome.\n","readmeTruncated":false}