fork from scoresaber-reloaded

This commit is contained in:
Lee
2023-10-17 21:42:37 +01:00
commit cc884eec07
229 changed files with 31236 additions and 0 deletions

13
src/network/utils.js Normal file
View File

@ -0,0 +1,13 @@
export const parseRateLimitHeaders = response => {
if (!response || !response.headers) return null;
const remaining = parseInt(response.headers.get('x-ratelimit-remaining'), 10);
const limit = parseInt(response.headers.get('x-ratelimit-limit'), 10);
const resetAt = parseInt(response.headers.get('x-ratelimit-reset'), 10);
return {
remaining: !isNaN(remaining) ? remaining : null,
limit: !isNaN(limit) ? limit : null,
resetAt: !isNaN(resetAt) ? new Date(resetAt * 1000) : null,
}
}