Skip to content

Commit

Permalink
Refactored from forEach to for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
gnought committed Sep 2, 2019
1 parent 573adfa commit 5606825
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/handlers/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ function SubscribeState (client, packet, finish, granted) {
// if same subscribed topic in subs array, we pick up the last one
function _dedupe (subs) {
var dedupeSubs = {}
subs.forEach(function (el) {
dedupeSubs[el.topic] = el
})
for (var i = 0; i < subs.length; i++) {
var sub = subs[i]
dedupeSubs[sub.topic] = sub
}
var ret = []
for (var key in dedupeSubs) {
ret.push(dedupeSubs[key])
Expand Down

0 comments on commit 5606825

Please sign in to comment.