diff options
author | mat <github@matdoes.dev> | 2022-03-25 21:13:13 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-03-25 21:13:13 -0500 |
commit | 6b94d0110a52a355758432ff6cd14c80553471ea (patch) | |
tree | 8113e5ee126b56f2d7e31309b5fa1fd65d008a77 /src/cleaners/skyblock/profiles.ts | |
parent | 7f4e9c598d4697e63602bc36f9034610cac84604 (diff) | |
download | skyblock-api-6b94d0110a52a355758432ff6cd14c80553471ea.tar.gz skyblock-api-6b94d0110a52a355758432ff6cd14c80553471ea.tar.bz2 skyblock-api-6b94d0110a52a355758432ff6cd14c80553471ea.zip |
Add typed-hypixel-api as a dep and change some code
Diffstat (limited to 'src/cleaners/skyblock/profiles.ts')
-rw-r--r-- | src/cleaners/skyblock/profiles.ts | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/cleaners/skyblock/profiles.ts b/src/cleaners/skyblock/profiles.ts index 20c2104..ddab078 100644 --- a/src/cleaners/skyblock/profiles.ts +++ b/src/cleaners/skyblock/profiles.ts @@ -5,8 +5,11 @@ import { CleanProfile, cleanSkyblockProfileResponse } from './profile.js' +import { SkyBlockProfilesResponse } from 'typed-hypixel-api/build/responses/skyblock/profiles' + +export function cleanPlayerSkyblockProfiles(rawProfiles: HypixelPlayerStatsSkyBlockProfiles | undefined): CleanBasicProfile[] { + if (!rawProfiles) return [] -export function cleanPlayerSkyblockProfiles(rawProfiles: HypixelPlayerStatsSkyBlockProfiles): CleanBasicProfile[] { let profiles: CleanBasicProfile[] = [] for (const profile of Object.values(rawProfiles ?? {})) { profiles.push({ @@ -18,11 +21,11 @@ export function cleanPlayerSkyblockProfiles(rawProfiles: HypixelPlayerStatsSkyBl } /** Convert an array of raw profiles into clean profiles */ -export async function cleanSkyblockProfilesResponse(data: any[]): Promise<CleanProfile[]> { - const promises: Promise<CleanProfile | CleanFullProfile | null>[] = [] - for (const profile of data ?? []) { +export async function cleanSkyblockProfilesResponse(data: SkyBlockProfilesResponse['profiles']): Promise<CleanFullProfile[]> { + const promises: Promise<CleanFullProfile | null>[] = [] + for (const profile of data) { promises.push(cleanSkyblockProfileResponse(profile)) } - const cleanedProfiles: CleanProfile[] = (await Promise.all(promises)).filter(p => p) as CleanProfile[] + const cleanedProfiles: CleanFullProfile[] = (await Promise.all(promises)).filter((p): p is CleanFullProfile => p !== null) return cleanedProfiles } |