create-torrent
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -6,2 +6,3 @@ var BlockStream = require('block-stream') | ||
var crypto = require('crypto') | ||
var flatten = require('lodash.flatten') | ||
var fs = require('fs') | ||
@@ -64,3 +65,5 @@ var inherits = require('inherits') | ||
var tasks = arr.map(function (item) { | ||
return fn.bind(undefined, item) | ||
return function (cb) { | ||
fn(item, cb) | ||
} | ||
}) | ||
@@ -173,2 +176,4 @@ parallel(tasks, cb) | ||
files = flatten(files) | ||
var length = files.reduce(sumLength, 0) | ||
@@ -175,0 +180,0 @@ |
{ | ||
"name": "create-torrent", | ||
"description": "Create .torrent files", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"author": "Feross Aboukhadijeh <feross@feross.org> (http://feross.org/)", | ||
@@ -13,2 +13,3 @@ "bugs": { | ||
"inherits": "^2.0.1", | ||
"lodash.flatten": "^2.4.1", | ||
"once": "^1.3.0", | ||
@@ -15,0 +16,0 @@ "piece-length": "^0.0.0", |
var bncode = require('bncode') | ||
var createTorrent = require('../') | ||
var crypto = require('crypto') | ||
var fs = require('fs') | ||
var parseTorrent = require('parse-torrent') | ||
@@ -12,3 +11,2 @@ var test = require('tape') | ||
var leavesPath = __dirname + '/content/Leaves of Grass by Walt Whitman.epub' | ||
@@ -18,2 +16,4 @@ test('create single file torrent', function (t) { | ||
var leavesPath = __dirname + '/content/Leaves of Grass by Walt Whitman.epub' | ||
var startTime = Date.now() | ||
@@ -74,3 +74,2 @@ createTorrent(leavesPath, function (err, torrent) { | ||
var numbersPath = __dirname + '/content/numbers' | ||
@@ -80,2 +79,4 @@ test('create multi file torrent', function (t) { | ||
var numbersPath = __dirname + '/content/numbers' | ||
var startTime = Date.now() | ||
@@ -127,1 +128,63 @@ createTorrent(numbersPath, { | ||
}) | ||
test('create multi file torrent with nested directories', function (t) { | ||
t.plan(22) | ||
var numbersPath = __dirname + '/content/lots-of-numbers' | ||
var startTime = Date.now() | ||
createTorrent(numbersPath, { | ||
pieceLength: 32768, // force piece length to 32KB so info-hash will | ||
// match what transmission generataed, since we use | ||
// a different algo for picking piece length | ||
private: false // also force `private: false` to match transmission | ||
}, function (err, torrent) { | ||
t.error(err) | ||
var parsedTorrent = parseTorrent(torrent) | ||
t.equals(parsedTorrent.name, 'lots-of-numbers') | ||
t.notOk(parsedTorrent.private) | ||
var createdTime = parsedTorrent.created / 1000 | ||
t.ok(createdTime >= startTime, 'created time is after start time') | ||
t.ok(createdTime <= Date.now(), 'created time is before now') | ||
t.deepEquals(parsedTorrent.announceList, [ | ||
['udp://tracker.publicbt.com:80/announce'], | ||
['udp://tracker.openbittorrent.com:80/announce'] | ||
]) | ||
t.deepEquals(parsedTorrent.files[0].path, 'lots-of-numbers/big numbers/10.txt') | ||
t.deepEquals(parsedTorrent.files[0].length, 2) | ||
t.deepEquals(parsedTorrent.files[1].path, 'lots-of-numbers/big numbers/11.txt') | ||
t.deepEquals(parsedTorrent.files[1].length, 2) | ||
t.deepEquals(parsedTorrent.files[2].path, 'lots-of-numbers/big numbers/12.txt') | ||
t.deepEquals(parsedTorrent.files[2].length, 2) | ||
t.deepEquals(parsedTorrent.files[3].path, 'lots-of-numbers/small numbers/1.txt') | ||
t.deepEquals(parsedTorrent.files[3].length, 1) | ||
t.deepEquals(parsedTorrent.files[4].path, 'lots-of-numbers/small numbers/2.txt') | ||
t.deepEquals(parsedTorrent.files[4].length, 2) | ||
t.deepEquals(parsedTorrent.files[5].path, 'lots-of-numbers/small numbers/3.txt') | ||
t.deepEquals(parsedTorrent.files[5].length, 3) | ||
t.equal(parsedTorrent.length, 12) | ||
t.equal(parsedTorrent.pieceLength, 32768) | ||
t.deepEquals(parsedTorrent.pieces, [ | ||
'47972f2befaee58b6f3860cd39bd56cb33a488f0' | ||
]) | ||
t.equals(sha1(parsedTorrent.infoBuffer), '427887e9c03e123f9c8458b1947090edf1c75baa') | ||
}) | ||
}) |
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
413795
17
300
1
7
+ Addedlodash.flatten@^2.4.1
+ Addedlodash._arraypool@2.4.1(transitive)
+ Addedlodash._basebind@2.4.1(transitive)
+ Addedlodash._basecreate@2.4.1(transitive)
+ Addedlodash._basecreatecallback@2.4.1(transitive)
+ Addedlodash._basecreatewrapper@2.4.1(transitive)
+ Addedlodash._baseflatten@2.4.1(transitive)
+ Addedlodash._baseisequal@2.4.1(transitive)
+ Addedlodash._createwrapper@2.4.1(transitive)
+ Addedlodash._getarray@2.4.1(transitive)
+ Addedlodash._isnative@2.4.1(transitive)
+ Addedlodash._maxpoolsize@2.4.1(transitive)
+ Addedlodash._objecttypes@2.4.1(transitive)
+ Addedlodash._releasearray@2.4.1(transitive)
+ Addedlodash._setbinddata@2.4.1(transitive)
+ Addedlodash._shimkeys@2.4.1(transitive)
+ Addedlodash._slice@2.4.1(transitive)
+ Addedlodash.bind@2.4.1(transitive)
+ Addedlodash.createcallback@2.4.4(transitive)
+ Addedlodash.flatten@2.4.1(transitive)
+ Addedlodash.forin@2.4.1(transitive)
+ Addedlodash.forown@2.4.1(transitive)
+ Addedlodash.identity@2.4.1(transitive)
+ Addedlodash.isarguments@2.4.1(transitive)
+ Addedlodash.isarray@2.4.1(transitive)
+ Addedlodash.isfunction@2.4.1(transitive)
+ Addedlodash.isobject@2.4.1(transitive)
+ Addedlodash.keys@2.4.1(transitive)
+ Addedlodash.map@2.4.1(transitive)
+ Addedlodash.noop@2.4.1(transitive)
+ Addedlodash.property@2.4.1(transitive)
+ Addedlodash.support@2.4.1(transitive)