swc/crates/swc_bundler/tests/.cache/deno/27641063817a82fd723ecc0f8be06d7cd7d4c4e1.ts
2021-11-09 20:42:49 +09:00

21 lines
575 B
TypeScript

// Loaded from https://deno.land/x/discordeno@11.0.0-rc.2/src/rest/check_rate_limits.ts
import { rest } from "./rest.ts";
/** Check the rate limits for a url or a bucket. */
export function checkRateLimits(url: string) {
const ratelimited = rest.ratelimitedPaths.get(url);
const global = rest.ratelimitedPaths.get("global");
const now = Date.now();
if (ratelimited && now < ratelimited.resetTimestamp) {
return ratelimited.resetTimestamp - now;
}
if (global && now < global.resetTimestamp) {
return global.resetTimestamp - now;
}
return false;
}