/** * Token-bucket rate limiter. * * A bucket of `capacity` tokens refills at `refillRate` tokens per second. * Every request consumes one token; if the bucket is empty, the request is * rejected. Allows *controlled burst* — an idle caller accumulates a full * bucket and can spend it at once, then drops to the steady rate. * * State is stored as a single JSON blob per key: `{ tokens, updatedAt }`. * Tokens are recomputed on read from the elapsed time — no background * timer needed. * * Because token accounting is more than a simple counter, this reads the * state, recomputes, and writes it back. When the store exposes the * optional atomic `compareAndSet` (the bundled memory and Redis stores * both do), the write is a CAS retried on contention — concurrent * requests can never double-spend a token. Stores without it fall back * to a last-writer-wins `set`, which can race under concurrency. * * @param {import('../index.js').BucketLimiterConfig} config * @returns {import('../index.js').Limiter} */ export function tokenBucket(config: import("../index.js").BucketLimiterConfig): import("../index.js").Limiter;