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-04-21 09:51:59 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-04-21 09:51:59 +0300
commit891e7e3fc2a0780cab9fdf64f699e713207b9604 (patch)
tree28008b5c1bf2905d9fc01817ba9cf5200d75100a /lib/file.js
parente311e0b7cb26437118e565674bffdfc0723492f7 (diff)
move method comments to api doc
Diffstat (limited to 'lib/file.js')
-rw-r--r--lib/file.js37
1 files changed, 2 insertions, 35 deletions
diff --git a/lib/file.js b/lib/file.js
index fd24e0e..bfa032e 100644
--- a/lib/file.js
+++ b/lib/file.js
@@ -1,3 +1,5 @@
+// TODO: cleanup reference to torrent (i.e. Torrent object)
+
module.exports = File
var eos = require('end-of-stream')
@@ -12,10 +14,6 @@ var streamToBuffer = require('stream-with-known-length-to-buffer')
inherits(File, EventEmitter)
-/**
- * @param {Torrent} torrent torrent that the file belongs to
- * @param {Object} file file object from the parsed torrent
- */
function File (torrent, file) {
EventEmitter.call(this)
@@ -40,33 +38,16 @@ function File (torrent, file) {
}
}
-/**
- * Selects the file to be downloaded, but at a lower priority than files with streams.
- * Useful if you know you need the file at a later stage.
- */
File.prototype.select = function (priority) {
if (this.length === 0) return
this._torrent.select(this._startPiece, this._endPiece, priority)
}
-/**
- * Deselects the file, which means it won't be downloaded unless someone creates a stream
- * for it.
- */
File.prototype.deselect = function () {
if (this.length === 0) return
this._torrent.deselect(this._startPiece, this._endPiece, false)
}
-/**
- * Create a readable stream to the file. Pieces needed by the stream will be prioritized
- * highly and fetched from the swarm first.
- *
- * @param {Object=} opts
- * @param {number} opts.start start stream at byte (inclusive)
- * @param {number} opts.end end stream at byte (inclusive)
- * @return {FileStream}
- */
File.prototype.createReadStream = function (opts) {
var self = this
if (this.length === 0) {
@@ -89,35 +70,21 @@ File.prototype.createReadStream = function (opts) {
return fileStream
}
-/**
- * @param {function} cb
- */
File.prototype.getBuffer = function (cb) {
streamToBuffer(this.createReadStream(), this.length, cb)
}
-/**
- * @param {function} cb
- */
File.prototype.getBlobURL = function (cb) {
if (typeof window === 'undefined') throw new Error('browser-only method')
var mime = render.mime[path.extname(this.name).toLowerCase()]
streamToBlobURL(this.createReadStream(), mime, cb)
}
-/**
- * @param {Element|string} elem
- * @param {function} cb
- */
File.prototype.appendTo = function (elem, cb) {
if (typeof window === 'undefined') throw new Error('browser-only method')
render.append(this, elem, cb)
}
-/**
- * @param {Element|string} elem
- * @param {function} cb
- */
File.prototype.renderTo = function (elem, cb) {
if (typeof window === 'undefined') throw new Error('browser-only method')
render.render(this, elem, cb)