Skip to content

Commit

Permalink
update function trackersToMap
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieularere-msq committed Aug 31, 2023
1 parent ecd61fe commit 641c597
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,11 @@ function isValidVastTracker(trackers, trackerToAdd) {
}

function trackersToMap(trackers) {
let trackersMap = new Map();
trackers.forEach(tracker => {
if (!trackersMap.get(tracker['event'])) {
trackersMap.set(tracker['event'], [tracker['url']])
} else {
trackersMap.get(tracker['event']).push(tracker['url']);
}
});
return trackersMap;
return trackers.reduce((map, {url, event}) => {
!map.has(event) && map.set(event, [])
map.get(event).push(url);
return map;
}, new Map())
}

export function addImpUrlToTrackers(bid, trackersMap) {
Expand Down

0 comments on commit 641c597

Please sign in to comment.