{"id":"ptekspy/reatelimit","name":"reatelimit","scope":"ptekspy","platform":"roblox","description":"Rate Limit","version":"1.0.2","latest":"1.0.2","versions":["1.0.2"],"license":"Apache-2.0","licenseRating":"safe","licenseCaveats":["Modified files must carry a notice of changes. If the package ships a NOTICE file, its attributions must be preserved."],"licenseVerified":true,"dependencies":{},"integrity":"500dc5a7ca542d95c3e90beccd22b07b7b2ccbfc4dca29e41abc83b2cfe8a302","likes":0,"downloads":0,"install":"forest install ptekspy/reatelimit","url":"https://forest.dev/p/roblox/ptekspy/reatelimit","files":"https://api.forest.dev/ai/package/roblox/ptekspy/reatelimit/files","readme":"# RateLimit\r\n\r\nA small Luau rate-limiting utility for Roblox that helps protect remote event handlers and other per-source workflows from spam.\r\n\r\n## Overview\r\n\r\n`RateLimit` provides a lightweight per-source limiter with optional strict wait behavior. It is designed to work with any source value, including `Player` instances, and automatically cleans up player references when players leave the game.\r\n\r\n### Key features\r\n\r\n- Rate limits by source value\r\n- Configurable events-per-second limit\r\n- Optional strict wait mode for evenly spaced event processing\r\n- Automatic cleanup for leaving `Player` instances\r\n- Simple API with `New`, `CheckRate`, `CleanSource`, `Cleanup`, and `Destroy`\r\n\r\n## Installation\r\n\r\nInstall the package with Wally:\r\n\r\n```bash\r\nwally add ptekspy/RateLimit\r\n```\r\n\r\n## Usage\r\n\r\nRequire the module from your package path. Adjust the path to your package structure.\r\n\r\n```lua\r\nlocal RateLimit = require(path.to.RateLimit.init)\r\n\r\nlocal limiter = RateLimit.New(5)\r\n\r\nif limiter:CheckRate(player) then\r\n\t-- process the action\r\nelse\r\n\t-- drop or ignore the action\r\nend\r\n```\r\n\r\n## API\r\n\r\n### `RateLimit.New(rate, is_full_wait?)`\r\n\r\nCreates a new rate limiter.\r\n\r\n- `rate` (`number`): allowed events per second.\r\n- `is_full_wait` (`boolean?`): if `true`, the limiter enforces a full wait period between allowed events; if `false`, it allows bursty behavior up to the configured rate.\r\n\r\nReturns a `RateLimit` instance.\r\n\r\n### `RateLimit:CheckRate(source)`\r\n\r\nChecks whether the provided source may proceed.\r\n\r\n- `source` (`any`): any value to rate limit by, such as a `Player` instance, user ID, or string key.\r\n\r\nReturns `true` when the event should be processed, otherwise `false`.\r\n\r\n### `RateLimit:CleanSource(source)`\r\n\r\nForgets a single source. Use this when a non-player source will no longer be reused.\r\n\r\n### `RateLimit:Cleanup()`\r\n\r\nForgets all tracked sources for this rate limiter.\r\n\r\n### `RateLimit:Destroy()`\r\n\r\nStops tracking the limiter internally and clears its state.\r\n\r\n## Notes\r\n\r\n- Player objects are automatically cleaned when they leave the game.\r\n- A `nil` source is normalized internally to a string key so it can still be rate limited.\r\n\r\n## Development\r\n\r\nTo build the package, use:\r\n\r\n```bash\r\nargon build\r\n```\r\n\r\n## License\r\n\r\nMIT License. See `LICENSE.md` for details.\r\n","readmeTruncated":false}