function takeToken
takeToken(
key: string,
limit: RateLimit
): boolean

Takes one token from key's bucket, or returns false when it is empty. The caller picks the key, such as typing:<userId>, and keys by user or account so that more tabs or parallel requests don't buy more tokens.

Parameters

key: string

Return Type

boolean

Usage

import { takeToken } from "api/lib/rate-limit.ts";