mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 11:17:05 +02:00
fix: formatted tankopedia arrays not using promise
This commit is contained in:
1 parent
423ad4e433
commit
fb66027de0
5 files changed
+13
-8
No files matched your search
@@ -6,7 +6,7 @@ export default async function resolveTankId(tank: string) {
|
||||
const number = parseInt(tank);
|
||||
|
||||
if (Number.isNaN(number)) {
|
||||
const searchResult = go(tank, TANKS, { keys: ['name'], limit: 1 });
|
||||
const searchResult = go(tank, await TANKS, { keys: ['name'], limit: 1 });
|
||||
|
||||
if (searchResult.length === 0) {
|
||||
throw throwError(
|
||||
|
||||
@@ -23,10 +23,15 @@ export const tankopedia = fetch('https://www.blitzstars.com/bs-tankopedia.json')
|
||||
console.log('Tankopedia cached');
|
||||
return (wrapperTankopedia as { data: Tankopedia }).data;
|
||||
});
|
||||
const entries = Object.entries(tankopedia);
|
||||
export const TANK_IDS = entries.map(([, { tank_id }]) => tank_id as number);
|
||||
export const TANKS = entries.map(([, entry]) => entry as TankopediaEntry);
|
||||
export const TANK_NAMES = entries.map(([, { name }]) => name);
|
||||
const entries = new Promise<TankopediaEntry[]>(async (resolve) => {
|
||||
resolve(Object.entries(await tankopedia).map(([, entry]) => entry));
|
||||
});
|
||||
export const TANKS = new Promise<TankopediaEntry[]>(async (resolve) => {
|
||||
resolve((await entries).map((entry) => entry));
|
||||
});
|
||||
export const TANK_NAMES = new Promise<string[]>(async (resolve) => {
|
||||
resolve((await entries).map(({ name }) => name));
|
||||
});
|
||||
|
||||
export const TANK_ICONS: Record<TankType, string> = {
|
||||
'AT-SPG': 'https://i.imgur.com/BIHSEH0.png',
|
||||
|
||||
Reference in new issue
Block a user