mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 03:07:04 +02:00
39 lines
838 B
TypeScript
39 lines
838 B
TypeScript
import { RatingInfo } from '../../commands/ratingLeaderboard';
|
|
import { Region } from '../../constants/regions';
|
|
import { asset } from './asset';
|
|
import { superDecompress } from './superDecompress';
|
|
|
|
const cache: Record<
|
|
Region,
|
|
Record<
|
|
number,
|
|
RatingInfo & {
|
|
detail: undefined;
|
|
}
|
|
>
|
|
> = {
|
|
com: {},
|
|
eu: {},
|
|
asia: {},
|
|
};
|
|
|
|
export default async function getArchivedRatingInfo(
|
|
region: Region,
|
|
season: number,
|
|
) {
|
|
if (!cache[region][season]) {
|
|
const info = await fetch(
|
|
asset(`regions/${region}/rating/${season}/info.cdon.lz4`),
|
|
)
|
|
.then((response) => response.arrayBuffer())
|
|
.then((buffer) =>
|
|
superDecompress<RatingInfo & { detail: undefined }>(
|
|
new Uint8Array(buffer),
|
|
),
|
|
);
|
|
cache[region][season] = info;
|
|
}
|
|
|
|
return cache[region][season];
|
|
}
|