diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-01-15 04:06:05 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-01-15 04:06:05 +0300 |
commit | 6f89456317a5383d07e5041b049497c9f5151335 (patch) | |
tree | 9de23ea297310315fb8adc6711de6802fa4f48d1 | |
parent | 816d6972d87a77d2569e3e311d6aa031e1fc369c (diff) |
style
-rw-r--r-- | index.js | 9 | ||||
-rw-r--r-- | lib/torrent.js | 3 |
2 files changed, 4 insertions, 8 deletions
@@ -163,11 +163,8 @@ WebTorrent.prototype.download = function (torrentId, opts, ontorrent) { var self = this if (self.destroyed) throw new Error('client is destroyed') if (typeof opts === 'function') return self.add(torrentId, null, opts) + opts = opts ? extend(opts) : {} debug('add') - if (!opts) opts = {} - else opts = extend(opts) - - opts.client = self var torrent = self.get(torrentId) @@ -179,6 +176,7 @@ WebTorrent.prototype.download = function (torrentId, opts, ontorrent) { if (torrent.ready) process.nextTick(_ontorrent) else torrent.on('ready', _ontorrent) } else { + opts.client = self torrent = new Torrent(torrentId, opts) self.torrents.push(torrent) @@ -210,9 +208,8 @@ WebTorrent.prototype.seed = function (input, opts, onseed) { var self = this if (self.destroyed) throw new Error('client is destroyed') if (typeof opts === 'function') return self.seed(input, null, opts) + opts = opts ? extend(opts) : {} debug('seed') - if (!opts) opts = {} - else opts = extend(opts) // When seeding from filesystem, initialize store from that path (avoids a copy) if (typeof input === 'string') opts.path = path.dirname(input) diff --git a/lib/torrent.js b/lib/torrent.js index 794a46d..2cd9fd6 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -1214,9 +1214,8 @@ Torrent.prototype.load = function (streams, cb) { } Torrent.prototype.createServer = function (opts) { - if (this.destroyed) throw new Error('torrent is destroyed') - if (typeof Server !== 'function') throw new Error('node.js-only method') + if (this.destroyed) throw new Error('torrent is destroyed') var server = new Server(this, opts) this._servers.push(server) return server |