Skip to content

Commit 0585d8b

Browse files
committed
use delete obj[key] instead of obj[key] = null
1 parent 32c2e98 commit 0585d8b

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

lib/client/websocket-tracker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ WebSocketTracker.prototype.destroy = function (onclose) {
7070
self.destroyed = true
7171
clearInterval(self.interval)
7272

73-
socketPool[self.announceUrl] = null
73+
delete socketPool[self.announceUrl]
7474

7575
self.socket.removeListener('connect', self._onSocketConnectBound)
7676
self.socket.removeListener('data', self._onSocketDataBound)
@@ -208,7 +208,7 @@ WebSocketTracker.prototype._onSocketData = function (data) {
208208

209209
clearTimeout(peer.trackerTimeout)
210210
peer.trackerTimeout = null
211-
self.peers[offerId] = null
211+
delete self.peers[offerId]
212212
} else {
213213
debug('got unexpected answer: ' + JSON.stringify(data.answer))
214214
}
@@ -281,7 +281,7 @@ WebSocketTracker.prototype._generateOffers = function (numwant, cb) {
281281
peer.trackerTimeout = setTimeout(function () {
282282
debug('tracker timeout: destroying peer')
283283
peer.trackerTimeout = null
284-
self.peers[offerId] = null
284+
delete self.peers[offerId]
285285
peer.destroy()
286286
}, OFFER_TIMEOUT)
287287
}

lib/server/swarm.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ Swarm.prototype._getPeers = function (numwant, ownPeerId, isWebRTC) {
103103
var peerId
104104
while ((peerId = ite()) && peers.length < numwant) {
105105
var peer = this.peers[peerId]
106-
if (!peer) continue
107106
if (isWebRTC && peer.peerId === ownPeerId) continue // don't send peer to itself
108107
if ((isWebRTC && peer.ip) || (!isWebRTC && peer.socket)) continue // send proper peer type
109108
peers.push(peer)

0 commit comments

Comments
 (0)