Skip to content

Commit 287cd87

Browse files
committed
remove extend.js
1 parent c2fb38b commit 287cd87

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

client.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ var compact2string = require('compact2string')
77
var debug = require('debug')('bittorrent-tracker')
88
var dgram = require('dgram')
99
var EventEmitter = require('events').EventEmitter
10-
var extend = require('extend.js')
1110
var get = require('simple-get')
1211
var hat = require('hat')
1312
var inherits = require('inherits')
@@ -218,10 +217,10 @@ Tracker.prototype.destroy = function () {
218217
*/
219218
Tracker.prototype._announce = function (opts) {
220219
var self = this
221-
opts = extend({
222-
uploaded: 0, // default, user should provide real value
223-
downloaded: 0 // default, user should provide real value
224-
}, opts)
220+
221+
// defaults, user should provide real values
222+
if (!opts.uploaded) opts.uploaded = 0
223+
if (!opts.downloaded) opts.downloaded = 0
225224

226225
if (self.client.torrentLength != null && opts.left == null) {
227226
opts.left = self.client.torrentLength - (opts.downloaded || 0)
@@ -262,17 +261,13 @@ Tracker.prototype._requestHttp = function (requestUrl, opts) {
262261
var self = this
263262

264263
if (opts._scrape) {
265-
opts = extend({
266-
info_hash: self.client._infoHash.toString('binary')
267-
}, opts)
264+
if (!opts.info_hash) opts.info_hash = self.client._infoHash.toString('binary')
268265
} else {
269-
opts = extend({
270-
info_hash: self.client._infoHash.toString('binary'),
271-
peer_id: self.client._peerId.toString('binary'),
272-
port: self.client._port,
273-
compact: 1,
274-
numwant: self.client._numWant
275-
}, opts)
266+
if (!opts.info_hash) opts.info_hash = self.client._infoHash.toString('binary')
267+
if (!opts.peer_id) opts.peer_id = self.client._peerId.toString('binary')
268+
if (!opts.port) opts.port = self.client._port
269+
if (!opts.compact) opts.compact = 1
270+
if (!opts.numwant) opts.numwant = self.client._numWant
276271

277272
if (self._trackerId) {
278273
opts.trackerid = self._trackerId

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"buffer-equal": "0.0.1",
2020
"compact2string": "^1.2.0",
2121
"debug": "^2.0.0",
22-
"extend.js": "0.0.2",
2322
"hat": "0.0.3",
2423
"inherits": "^2.0.1",
2524
"ip": "^0.3.0",

0 commit comments

Comments
 (0)