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 3.1.1 to 3.2.0

40

index.js

@@ -56,7 +56,4 @@ module.exports = createTorrent

}
if (isBlob(item)) file.stream = new FileReadStream(item)
else if (Buffer.isBuffer(item)) {
file.stream = new stream.PassThrough()
file.stream.end(item)
}
if (isBlob(item)) file.getStream = getBlobStream(item)
else if (Buffer.isBuffer(item)) file.getStream = getBufferStream(item)
else throw new Error('Array must contain only File objects')

@@ -80,3 +77,3 @@ return file

files.forEach(function (file) {
file.stream = fs.createReadStream(file.path)
file.getStream = getFSStream(file.path)
file.path = file.path.replace(dirName, '').split(corePath.sep)

@@ -92,2 +89,24 @@ })

function getBlobStream(data) {
return function() {
return new FileReadStream(data)
}
}
function getBufferStream(data) {
return function() {
var stream = new stream.PassThrough()
stream.end(data)
return stream
}
}
function getFSStream(data) {
return function() {
return fs.createReadStream(data)
}
}
createTorrent.announceList = [

@@ -143,3 +162,3 @@ [ 'udp://tracker.publicbt.com:80' ],

var streams = files.map(function (file) {
return file.stream
return file.getStream
})

@@ -155,6 +174,3 @@

})
.on('error', function (err) {
console.error(err)
cb(err)
})
.on('error', cb)
}

@@ -208,3 +224,3 @@

files.forEach(function (file) {
delete file.stream
delete file.getStream
})

@@ -211,0 +227,0 @@

{
"name": "create-torrent",
"description": "Create .torrent files",
"version": "3.1.1",
"version": "3.2.0",
"author": "Feross Aboukhadijeh <feross@feross.org> (http://feross.org/)",

@@ -6,0 +6,0 @@ "bin": {

@@ -0,1 +1,2 @@

var path = require('path')
var createTorrent = require('../')

@@ -36,3 +37,3 @@ var crypto = require('crypto')

t.equals(parsedTorrent.files[0].path, 'Leaves of Grass by Walt Whitman.epub')
t.equals(path.normalize(parsedTorrent.files[0].path), path.normalize('Leaves of Grass by Walt Whitman.epub'))
t.equals(parsedTorrent.files[0].length, 362017)

@@ -106,9 +107,9 @@

t.deepEquals(parsedTorrent.files[0].path, 'numbers/1.txt')
t.deepEquals(path.normalize(parsedTorrent.files[0].path), path.normalize('numbers/1.txt'))
t.deepEquals(parsedTorrent.files[0].length, 1)
t.deepEquals(parsedTorrent.files[1].path, 'numbers/2.txt')
t.deepEquals(path.normalize(parsedTorrent.files[1].path), path.normalize('numbers/2.txt'))
t.deepEquals(parsedTorrent.files[1].length, 2)
t.deepEquals(parsedTorrent.files[2].path, 'numbers/3.txt')
t.deepEquals(path.normalize(parsedTorrent.files[2].path), path.normalize('numbers/3.txt'))
t.deepEquals(parsedTorrent.files[2].length, 3)

@@ -159,18 +160,18 @@

t.deepEquals(parsedTorrent.files[0].path, 'lots-of-numbers/big numbers/10.txt')
t.deepEquals(path.normalize(parsedTorrent.files[0].path), path.normalize('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(path.normalize(parsedTorrent.files[1].path), path.normalize('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(path.normalize(parsedTorrent.files[2].path), path.normalize('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(path.normalize(parsedTorrent.files[3].path), path.normalize('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(path.normalize(parsedTorrent.files[4].path), path.normalize('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(path.normalize(parsedTorrent.files[5].path), path.normalize('lots-of-numbers/small numbers/3.txt'))
t.deepEquals(parsedTorrent.files[5].length, 3)

@@ -177,0 +178,0 @@

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