Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 28x 28x 28x 28x 28x 28x 1x 1x 28x 1x 1x 28x 24x 24x 28x 1x 1x 28x 1x 28x 27x 27x 27x | import { HoyoAPIError } from '../../error' import { GenshinRegion, GenshinRegionKeyType } from './gi.interface' /** * Get Genshin Impact region based on UID. * * @param uid User ID. * @returns Region for the UID. * @throws `HoyoAPIError` when the UID is invalid. */ export function getGenshinRegion(uid: number): GenshinRegion { const server_region = Number(uid.toString().trim().slice(0, 1)) let key: string switch (server_region) { case 6: key = 'USA' break case 7: key = 'EUROPE' break case 8: key = 'ASIA' break case 9: key = 'CHINA_TAIWAN' break default: throw new HoyoAPIError(`Given UID ${uid} is invalid !`) } return GenshinRegion[key as GenshinRegionKeyType] } |