diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-04-21 09:51:59 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-04-21 09:51:59 +0300 |
commit | 891e7e3fc2a0780cab9fdf64f699e713207b9604 (patch) | |
tree | 28008b5c1bf2905d9fc01817ba9cf5200d75100a /lib/file.js | |
parent | e311e0b7cb26437118e565674bffdfc0723492f7 (diff) |
move method comments to api doc
Diffstat (limited to 'lib/file.js')
-rw-r--r-- | lib/file.js | 37 |
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) |