Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modernize lib/file.js #1478

Merged
merged 2 commits into from Aug 20, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

wrapped in parentheses

  • Loading branch information
jimmywarting committed Aug 19, 2018
commit 6386a6e75d260929098f68ccdc59603554e6bc3b
@@ -1,12 +1,12 @@
const eos = require('end-of-stream')
const {EventEmitter} = require('events')
const FileStream = require('./file-stream')
const {PassThrough} = require('readable-stream')
const eos = require('end-of-stream')
const path = require('path')
const render = require('render-media')
const stream = require('readable-stream')
const streamToBlob = require('stream-to-blob')
const streamToBlobURL = require('stream-to-blob-url')
const streamToBuffer = require('stream-with-known-length-to-buffer')
const FileStream = require('./file-stream')

class File extends EventEmitter {
constructor (torrent, file) {
@@ -40,7 +40,7 @@ class File extends EventEmitter {
for (let index = this._startPiece; index <= this._endPiece; ++index) {
if (this._torrent.bitfield.get(index)) {
// verified data
downloaded += index === this._endPiece ? this._torrent.lastPieceLength : this._torrent.pieceLength
downloaded += (index === this._endPiece) ? this._torrent.lastPieceLength : this._torrent.pieceLength
} else {
// "in progress" data
const piece = this._torrent.pieces[index]
@@ -66,7 +66,7 @@ class File extends EventEmitter {

createReadStream (opts) {
if (this.length === 0) {
const empty = new stream.PassThrough()
const empty = new PassThrough()
process.nextTick(() => {
empty.end()
})
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.