mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-13 20:56:11 +01:00
feat: core chunk 4
This commit is contained in:
1 parent
b827f7f730
commit
9bdb14e13a
22 files changed
+46
-31
No files matched your search
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user