Skip to content

Commit

Permalink
fix: Minor improvement to code
Browse files Browse the repository at this point in the history
  • Loading branch information
sruusk authored Mar 27, 2023
1 parent 8631ed4 commit b86a68f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ function getStat(
throw new Error(`No ${statName} stat found`);
}

function nullOrUndefined(value: any): boolean {
return value === null || value === undefined;
}

export async function getPlayer(
this: EseaScraper,
eseaProfileId: string | bigint
Expand Down Expand Up @@ -115,8 +111,8 @@ export async function getPlayer(
wins: wins,
kills: kills,
deaths: deaths,
rank: nullOrUndefined(profile.rank.placement_matches_remaining) ? profile.rank.current.rank : undefined,
mmr: nullOrUndefined(profile.rank.placement_matches_remaining) ? parseInt(profile.rank.current.mmr, 10) : undefined,
rank: !profile.rank.placement_matches_remaining ? profile.rank.current.rank : undefined,
mmr: !profile.rank.placement_matches_remaining ? parseInt(profile.rank.current.mmr, 10) : undefined,
matches: totalGames,
headshotRate: getStat(stats.stats, parseFloat, 'all.hs_percentage'),
averageDamageRound: getStat(stats.stats, parseFloat, 'all.adr'),
Expand Down

0 comments on commit b86a68f

Please sign in to comment.