Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2014-05-12 12:12:53 +0400
committerFeross Aboukhadijeh <feross@feross.org>2014-05-12 12:12:53 +0400
commitc95d8d947cb96c75d2f8a51e561af5fdd32dbd95 (patch)
tree1fadd535e55a5e9cffa1910985dc5c7c43a1d0dc /index.js
parent7b26cfb2e02e2ebbd6aa4d4bbd175e558d4625d8 (diff)
pass cb thru to client.add
Diffstat (limited to 'index.js')
-rw-r--r--index.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/index.js b/index.js
index 7ac8dc8..71a143f 100644
--- a/index.js
+++ b/index.js
@@ -32,7 +32,7 @@ function WebTorrent (opts) {
WebTorrent.prototype.add = function (torrentId, cb) {
var self = this
- if (!cb) cb = function () {}
+ if (typeof cb !== 'function') cb = function () {}
// TODO: support passing in an index to file to download
// self.index = opts.index
@@ -43,7 +43,7 @@ WebTorrent.prototype.add = function (torrentId, cb) {
// Called once we have a torrentId that bittorrent-client can handle
function onTorrentId (torrentId) {
- var torrent = Client.prototype.add.call(self, torrentId) // will emit 'torrent' event
+ var torrent = Client.prototype.add.call(self, torrentId, cb) // will emit 'torrent' event
cb(null, torrent)
}
@@ -78,7 +78,7 @@ WebTorrent.prototype.add = function (torrentId, cb) {
WebTorrent.prototype._onTorrent = function (torrent) {
var self = this
console.log('got metadata')
- console.log('files:\n', files.join('\n'))
+ console.log('files:\n', torrent.files.map(function (f) { return f.name }).join('\n'))
// if no index specified, use largest file
// TODO: support torrent index selection correctly -- this doesn't work yet