{"id":"yetanotherclown/token-bucket","name":"token-bucket","scope":"yetanotherclown","platform":"roblox","description":"A Token Bucket implementation for Luau","version":"0.1.0","latest":"0.1.0","versions":["0.1.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"3ccd9b3e0e89177b8fa9b821ddf59765884f37bf6235651c0c967946458ff85d","likes":0,"downloads":0,"install":"forest install yetanotherclown/token-bucket","url":"https://forest.dev/p/roblox/yetanotherclown/token-bucket","files":"https://api.forest.dev/ai/package/roblox/yetanotherclown/token-bucket/files","readme":"# Token Bucket\r\n\r\nA TokenBucket implementation for Luau.\r\n\r\n## Use\r\n\r\nTokenBucket is very simple to use, either see the [API](https://yetanotherclown.github.io/token-bucket-luau/api) or follow this example below.\r\n\r\n```lua\r\nlocal TokenBucket = require(\"@packages/TokenBucket\")\r\n\r\nlocal bucket = TokenBucket.new(10, 1)\r\n\r\n-- `TokenBucket:add()` should be called on a fixed interval\r\nlocal update = coroutine.create(function()\r\n    while wait(1) do\r\n        bucket:add()\r\n    end\r\nend)\r\n\r\ncoroutine.resume(update)\r\n\r\n-- `TokenBucket:remove()` is called to remove a token from the bucket\r\nlocal tokenWasRemoved = bucket:remove()\r\n\r\nif tokenWasRemoved == true then\r\n    -- This is when you drop the packet\r\nelseif tokenWasRemoved == false then\r\n    -- This is when you can forward the packet\r\nend\r\n```\r\n\r\n## Installation\r\n\r\nTokenBucket can be installed using Pesde and Wally, or you can simply copy and paste the source directly.\r\n\r\n### Pesde\r\n\r\nInstall from the command line with,\r\n\r\n```sh\r\n> pesde add yetanotherclown/token_bucket --target luau --alias TokenBucket\r\n```\r\n\r\nOr from your `pesde.toml`,\r\n\r\n```toml\r\n[dependencies]\r\nTokenBucket = { name = \"yetanotherclown/token_bucket\", version = \"^0.1.0\", target = \"luau\" }\r\n```\r\n\r\n### Wally\r\n\r\nInstall from your `wally.toml`,\r\n\r\n```toml\r\n[dependencies]\r\nTokenBucket = \"yetanotherclown/token-bucket@0.1.0\"\r\n```","readmeTruncated":false}