createTokenBucketStrategy
createTokenBucketStrategy(
config):RateLimitStrategy
Defined in: packages/core/src/rest/bucket.ts:24
Creates a header-driven token bucket strategy (used by Twitch, TwitCasting). Uses lazy refill: tokens are recalculated from elapsed time on each acquire() call. No timers, no cleanup needed.
Parameters
Section titled “Parameters”config
Section titled “config”token bucket configuration with limits, header parser, and platform name
Returns
Section titled “Returns”a RateLimitStrategy backed by a token bucket
Precondition
Section titled “Precondition”global.requests > 0 and global.perMs > 0
Postcondition
Section titled “Postcondition”acquire() rejects with RateLimitError when no tokens are available
Idempotency
Section titled “Idempotency”Not idempotent — each acquire() consumes a token