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>2016-07-27 08:44:21 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-07-27 08:44:21 +0300
commitaf0189ff2183ad04d35e6ec89de83d498e8719fa (patch)
tree28afbf0f7609c5fb8896e34cbafc76b16c71ab55 /index.js
parent6fd258d171cf7f12587687cf887c2fdc1ca24190 (diff)
Fix support for FileList input to client.seed()
Fixes #848
Diffstat (limited to 'index.js')
-rw-r--r--index.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/index.js b/index.js
index 70a2818..b0555fb 100644
--- a/index.js
+++ b/index.js
@@ -1,3 +1,5 @@
+/* global FileList */
+
module.exports = WebTorrent
var Buffer = require('safe-buffer').Buffer
@@ -300,7 +302,9 @@ WebTorrent.prototype.seed = function (input, opts, onseed) {
var torrent = self.add(null, opts, onTorrent)
var streams
+ if (isFileList(input)) input = Array.prototype.slice.call(input)
if (!Array.isArray(input)) input = [ input ]
+
parallel(input.map(function (item) {
return function (cb) {
if (isReadable(item)) concat(item, cb)
@@ -448,3 +452,12 @@ WebTorrent.prototype._onListening = function () {
function isReadable (obj) {
return typeof obj === 'object' && obj != null && typeof obj.pipe === 'function'
}
+
+/**
+ * Check if `obj` is a W3C `FileList` object
+ * @param {*} obj
+ * @return {boolean}
+ */
+function isFileList (obj) {
+ return typeof FileList !== 'undefined' && obj instanceof FileList
+}