Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function computeMatchData(pm) {
const selfHero = constants.heroes[pm.hero_id];
// Compute patch based on start_time
if (pm.start_time) {
pm.patch = utility.getPatchIndex(pm.start_time);
}
if (pm.cluster) {
pm.region = constants.cluster[pm.cluster];
}
if (pm.player_slot !== undefined && pm.radiant_win !== undefined) {
pm.isRadiant = isRadiant(pm);
pm.win = Number(isRadiant(pm) === pm.radiant_win);
pm.lose = Number(isRadiant(pm) === pm.radiant_win) ? 0 : 1;
}
if (pm.duration && pm.gold_per_min) {
pm.total_gold = Math.floor((pm.gold_per_min * pm.duration) / 60);
}
if (pm.duration && pm.xp_per_min) {
pm.total_xp = Math.floor((pm.xp_per_min * pm.duration) / 60);
}
if (pm.duration && pm.kills) {
pm.kills_per_min = pm.kills / (pm.duration / 60);
}
if (pm.kills !== undefined && pm.deaths !== undefined && pm.assists !== undefined) {