This repository has been archived on 2023-10-27. You can view files and clone it, but cannot push or open issues or pull requests.
Files
scoresaber-reloaded/src/network/utils.js

13 lines
507 B
JavaScript
Raw Normal View History

2023-10-17 21:42:37 +01:00
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,
}
}