Socket
Socket
Sign inDemoInstall

create-torrent

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-torrent - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

test/content/lots-of-numbers/big numbers/10.txt

7

index.js

@@ -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 @@

3

package.json
{
"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')
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc