Skip to content

Commit db4a06d

Browse files
committed
standard
1 parent 85e7a60 commit db4a06d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

server.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const parseHttpRequest = require('./lib/server/parse-http')
1515
const parseUdpRequest = require('./lib/server/parse-udp')
1616
const parseWebSocketRequest = require('./lib/server/parse-websocket')
1717

18+
const hasOwnProperty = Object.prototype.hasOwnProperty
19+
1820
/**
1921
* BitTorrent tracker server.
2022
*
@@ -147,7 +149,7 @@ class Server extends EventEmitter {
147149
let key
148150

149151
for (key in allPeers) {
150-
if (allPeers.hasOwnProperty(key) && filterFunction(allPeers[key])) {
152+
if (hasOwnProperty.call(allPeers, key) && filterFunction(allPeers[key])) {
151153
count++
152154
}
153155
}
@@ -158,7 +160,7 @@ class Server extends EventEmitter {
158160
function groupByClient () {
159161
const clients = {}
160162
for (const key in allPeers) {
161-
if (allPeers.hasOwnProperty(key)) {
163+
if (hasOwnProperty.call(allPeers, key)) {
162164
const peer = allPeers[key]
163165

164166
if (!clients[peer.client.client]) {
@@ -179,10 +181,10 @@ class Server extends EventEmitter {
179181
function printClients (clients) {
180182
let html = '<ul>\n'
181183
for (const name in clients) {
182-
if (clients.hasOwnProperty(name)) {
184+
if (hasOwnProperty.call(clients, name)) {
183185
const client = clients[name]
184186
for (const version in client) {
185-
if (client.hasOwnProperty(version)) {
187+
if (hasOwnProperty.call(client, version)) {
186188
html += `<li><strong>${name}</strong> ${version} : ${client[version]}</li>\n`
187189
}
188190
}
@@ -203,7 +205,7 @@ class Server extends EventEmitter {
203205
const peer = peers.peek(peerId)
204206
if (peer == null) return // peers.peek() can evict the peer
205207

206-
if (!allPeers.hasOwnProperty(peerId)) {
208+
if (!hasOwnProperty.call(allPeers, peerId)) {
207209
allPeers[peerId] = {
208210
ipv4: false,
209211
ipv6: false,

0 commit comments

Comments
 (0)