create-torrent
Advanced tools
Comparing version 3.9.1 to 3.9.2
52
index.js
@@ -1,2 +0,2 @@ | ||
/*global FileList */ | ||
/*global Blob, FileList */ | ||
@@ -27,3 +27,2 @@ module.exports = createTorrent | ||
var stream = require('stream') | ||
var Transform = stream.Transform | ||
@@ -64,13 +63,13 @@ /** | ||
if (isFileList(input)) | ||
input = Array.prototype.slice.call(input) | ||
if (!Array.isArray(input)) | ||
input = [ input ] | ||
if (Array.isArray(input) && input.length === 0) throw new Error('invalid input type') | ||
if (input.length === 0) throw new Error('invalid input type') | ||
if (isFileList(input)) input = Array.prototype.slice.call(input) | ||
if (!Array.isArray(input)) input = [ input ] | ||
if (!opts.name) | ||
opts.name = input[0].name || (typeof input[0] === 'string' && corePath.basename(input)) | ||
if (opts.name === undefined) | ||
if (!opts.name) opts.name = input[0] && input[0].name | ||
if (!opts.name) opts.name = typeof input[0] === 'string' && corePath.basename(input[0]) | ||
if (opts.name === undefined) { | ||
throw new Error('missing option \'name\' and unable to infer it from input[0].name') | ||
} | ||
@@ -95,4 +94,5 @@ // If there's just one file, allow the name to be set by `opts.name` | ||
} else if (isReadable(item)) { | ||
if (!opts.pieceLength) | ||
if (!opts.pieceLength) { | ||
throw new Error('must specify `pieceLength` option if input is Stream') | ||
} | ||
file.getStream = getStreamStream(item, file) | ||
@@ -114,7 +114,3 @@ file.length = 0 | ||
files = flatten(files) | ||
if (numPaths === 0) process.nextTick(function () { | ||
cb(null, files) // dezalgo | ||
}) | ||
else cb(null, files) | ||
cb(null, files) | ||
}) | ||
@@ -211,4 +207,5 @@ } | ||
function maybeDone () { | ||
if (ended && remainingHashes === 0) | ||
if (ended && remainingHashes === 0) { | ||
cb(null, new Buffer(pieces.join(''), 'hex'), length) | ||
} | ||
} | ||
@@ -234,10 +231,7 @@ } | ||
if (opts.comment !== undefined) | ||
torrent.info.comment = opts.comment | ||
if (opts.comment !== undefined) torrent.info.comment = opts.comment | ||
if (opts.createdBy !== undefined) | ||
torrent.info['created by'] = opts.createdBy | ||
if (opts.createdBy !== undefined) torrent.info['created by'] = opts.createdBy | ||
if (opts.private !== undefined) | ||
torrent.info.private = Number(opts.private) | ||
if (opts.private !== undefined) torrent.info.private = Number(opts.private) | ||
@@ -248,7 +242,5 @@ // "ssl-cert" key is for SSL torrents, see: | ||
// - http://www.libtorrent.org/reference-Create_Torrents.html | ||
if (opts.sslCert !== undefined) | ||
torrent.info['ssl-cert'] = opts.sslCert | ||
if (opts.sslCert !== undefined) torrent.info['ssl-cert'] = opts.sslCert | ||
if (opts.urlList !== undefined) | ||
torrent['url-list'] = opts.urlList | ||
if (opts.urlList !== undefined) torrent['url-list'] = opts.urlList | ||
@@ -358,5 +350,5 @@ var singleFile = files.length === 1 | ||
*/ | ||
function getStreamStream (stream, file) { | ||
function getStreamStream (readable, file) { | ||
return function () { | ||
var counter = new Transform() | ||
var counter = new stream.Transform() | ||
counter._transform = function (buf, enc, done) { | ||
@@ -367,5 +359,5 @@ file.length += buf.length | ||
} | ||
stream.pipe(counter) | ||
readable.pipe(counter) | ||
return counter | ||
} | ||
} |
{ | ||
"name": "create-torrent", | ||
"description": "Create .torrent files", | ||
"version": "3.9.1", | ||
"version": "3.9.2", | ||
"author": "Feross Aboukhadijeh <feross@feross.org> (http://feross.org/)", | ||
@@ -27,3 +27,3 @@ "bin": { | ||
"parse-torrent": "^4.0.0", | ||
"standard": "^2.6.5", | ||
"standard": "^3.2.0", | ||
"tape": "^3.0.3", | ||
@@ -30,0 +30,0 @@ "zuul": "^2.0.0" |
@@ -0,1 +1,3 @@ | ||
/*global Blob */ | ||
var createTorrent = require('../../') | ||
@@ -2,0 +4,0 @@ var fs = require('fs') |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
439913
846