API reference

petty.rateLimit

petty.rateLimit.canFire

canFire(id: string): boolean

True iff enough time has elapsed since the last fire(id) for the cooldown declared under manifest.rateLimits[id]. Ids with no declared cooldown always return true.

petty.rateLimit.fire

fire(id: string): void

Records the current timestamp for future canFire checks.

petty.rateLimit.reset

reset(id: string): void

Forgets the last-fired timestamp so the next canFire returns true.