Skip to content

chore(utils): Adjust JSDoc of rate limit functions #6748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/utils/src/ratelimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export function parseRetryAfterHeader(header: string, now: number = Date.now()):
}

/**
* Gets the time that given category is disabled until for rate limiting
* Gets the time that the given category is disabled until for rate limiting.
* In case no category-specific limit is set but a general rate limit across all categories is active,
* that time is returned.
*
* @return the time in ms that the category is disabled until or 0 if there's no active rate limit.
*/
export function disabledUntil(limits: RateLimits, category: string): number {
return limits[category] || limits.all || 0;
Expand All @@ -41,7 +45,8 @@ export function isRateLimited(limits: RateLimits, category: string, now: number

/**
* Update ratelimits from incoming headers.
* Returns true if headers contains a non-empty rate limiting header.
*
* @return the updated RateLimits object.
*/
export function updateRateLimits(
limits: RateLimits,
Expand Down