RateLimittypeno test imports ittype RateLimit = { readonly operations: number; readonly intervalMs: number };How many operations in how many milliseconds.
The rate-limited layer: at most a number of operations in an interval, by a token bucket that refills with the clock the caller gives. An operation over the limit waits through the sleep of the clock and is then made; the limit never fails an operation.
import { rateLimited } from "./rate-limited.ts";
// const store = rateLimited(inner, { operations: 10, intervalMs: 1000 }, clock)RateLimittypeno test imports ittype RateLimit = { readonly operations: number; readonly intervalMs: number };How many operations in how many milliseconds.
rateLimitedfunctionfunction rateLimited<C extends Capability>(store: Store<C>, limit: RateLimit, clock: Clock): Store<Carried<C>>A store that makes at most the operations of the limit in each interval, and keeps the capabilities of its argument.