feat: core chunk 4

This commit is contained in:
TrèsAbhi committed 2023-10-14 11:15:42 -05:00
1 parent b827f7f730
commit 9bdb14e13a
22 files changed
+46 -31

No files matched your search

+6 -3
View File
@@ -2,11 +2,14 @@ import { go } from 'fuzzysort';
import throwError from '../node/throwError';
import { TANKS, tankopedia } from './tankopedia';
export default async function resolveTankId(tank: string) {
const number = parseInt(tank);
export default async function resolveTankId(tank: string | number) {
const number = typeof tank === 'string' ? parseInt(tank) : tank;
if (Number.isNaN(number)) {
const searchResult = go(tank, await TANKS, { keys: ['name'], limit: 1 });
const searchResult = go(`${tank}`, await TANKS, {
keys: ['name'],
limit: 1,
});
if (searchResult.length === 0) {
throw throwError(