create-torrent
Advanced tools
Comparing version 3.20.3 to 3.21.0
30
index.js
@@ -18,3 +18,3 @@ module.exports = createTorrent | ||
var corePath = require('path') | ||
var dezalgo = require('dezalgo') | ||
var extend = require('xtend') | ||
var FileReadStream = require('filestream/read') | ||
@@ -47,8 +47,6 @@ var flatten = require('flatten') | ||
function createTorrent (input, opts, cb) { | ||
if (typeof opts === 'function') { | ||
cb = opts | ||
opts = {} | ||
} | ||
if (!opts) opts = {} | ||
parseInput(input, opts, function (err, files, singleFileTorrent) { | ||
if (typeof opts === 'function') return createTorrent(input, null, opts) | ||
opts = opts ? extend(opts) : {} | ||
_parseInput(input, opts, function (err, files, singleFileTorrent) { | ||
if (err) return cb(err) | ||
@@ -61,9 +59,11 @@ opts.singleFileTorrent = singleFileTorrent | ||
function parseInput (input, opts, cb) { | ||
if (typeof opts === 'function') { | ||
cb = opts | ||
opts = {} | ||
} | ||
if (!opts) opts = {} | ||
cb = dezalgo(cb) | ||
if (typeof opts === 'function') return parseInput(input, null, opts) | ||
opts = opts ? extend(opts) : {} | ||
_parseInput(input, opts, cb) | ||
} | ||
/** | ||
* Parse input file and return file information. | ||
*/ | ||
function _parseInput (input, opts, cb) { | ||
if (Array.isArray(input) && input.length === 0) throw new Error('invalid input type') | ||
@@ -143,3 +143,5 @@ | ||
} else { | ||
processInput() | ||
process.nextTick(function () { | ||
processInput() | ||
}) | ||
} | ||
@@ -146,0 +148,0 @@ |
{ | ||
"name": "create-torrent", | ||
"description": "Create .torrent files", | ||
"version": "3.20.3", | ||
"version": "3.21.0", | ||
"author": "Feross Aboukhadijeh <feross@feross.org> (http://feross.org/)", | ||
@@ -15,3 +15,2 @@ "bin": { | ||
"block-stream2": "^1.0.0", | ||
"dezalgo": "^1.0.1", | ||
"filestream": "^4.0.0", | ||
@@ -26,3 +25,4 @@ "flatten": "0.0.1", | ||
"run-parallel": "^1.0.0", | ||
"simple-sha1": "^2.0.0" | ||
"simple-sha1": "^2.0.0", | ||
"xtend": "^4.0.1" | ||
}, | ||
@@ -29,0 +29,0 @@ "devDependencies": { |
# create-torrent [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] | ||
[travis-image]: https://img.shields.io/travis/feross/create-torrent/master.svg?style=flat | ||
[travis-image]: https://img.shields.io/travis/feross/create-torrent/master.svg | ||
[travis-url]: https://travis-ci.org/feross/create-torrent | ||
[npm-image]: https://img.shields.io/npm/v/create-torrent.svg?style=flat | ||
[npm-image]: https://img.shields.io/npm/v/create-torrent.svg | ||
[npm-url]: https://npmjs.org/package/create-torrent | ||
[downloads-image]: https://img.shields.io/npm/dm/create-torrent.svg?style=flat | ||
[downloads-image]: https://img.shields.io/npm/dm/create-torrent.svg | ||
[downloads-url]: https://npmjs.org/package/create-torrent | ||
@@ -9,0 +9,0 @@ |
@@ -1,5 +0,5 @@ | ||
var path = require('path') | ||
var createTorrent = require('../') | ||
var fs = require('fs') | ||
var createTorrent = require('../') | ||
var parseTorrent = require('parse-torrent') | ||
var path = require('path') | ||
var sha1 = require('simple-sha1') | ||
@@ -11,3 +11,3 @@ var test = require('tape') | ||
var leavesPath = __dirname + '/content/Leaves of Grass by Walt Whitman.epub' | ||
var leavesPath = path.join(__dirname, 'content/Leaves of Grass by Walt Whitman.epub') | ||
@@ -82,3 +82,3 @@ var startTime = Date.now() | ||
var numbersPath = __dirname + '/content/numbers' | ||
var numbersPath = path.join(__dirname, 'content/numbers') | ||
@@ -131,3 +131,3 @@ var startTime = Date.now() | ||
var numbersPath = __dirname + '/content/lots-of-numbers' | ||
var numbersPath = path.join(__dirname, 'content/lots-of-numbers') | ||
@@ -189,3 +189,3 @@ var startTime = Date.now() | ||
var leavesPath = __dirname + '/content/Leaves of Grass by Walt Whitman.epub' | ||
var leavesPath = path.join(__dirname, 'content/Leaves of Grass by Walt Whitman.epub') | ||
var stream = fs.createReadStream(leavesPath) | ||
@@ -250,3 +250,3 @@ | ||
var numbersPath = __dirname + '/content/numbers' | ||
var numbersPath = path.join(__dirname, 'content/numbers') | ||
@@ -307,5 +307,5 @@ var files = fs.readdirSync(numbersPath).map(function (file) { | ||
var number10Path = __dirname + '/content/lots-of-numbers/big numbers/10.txt' | ||
var number11Path = __dirname + '/content/lots-of-numbers/big numbers/11.txt' | ||
var numbersPath = __dirname + '/content/numbers' | ||
var number10Path = path.join(__dirname, 'content/lots-of-numbers/big numbers/10.txt') | ||
var number11Path = path.join(__dirname, 'content/lots-of-numbers/big numbers/11.txt') | ||
var numbersPath = path.join(__dirname, 'content/numbers') | ||
@@ -367,5 +367,5 @@ var input = [ number10Path, number11Path, numbersPath ] | ||
var number11Path = __dirname + '/content/lots-of-numbers/big numbers/11.txt' | ||
var number10Path = __dirname + '/content/lots-of-numbers/big numbers/10.txt' | ||
var numbersPath = __dirname + '/content/numbers' | ||
var number11Path = path.join(__dirname, 'content/lots-of-numbers/big numbers/11.txt') | ||
var number10Path = path.join(__dirname, 'content/lots-of-numbers/big numbers/10.txt') | ||
var numbersPath = path.join(__dirname, 'content/numbers') | ||
@@ -372,0 +372,0 @@ var stream = fs.createReadStream(number10Path) |
@@ -6,2 +6,3 @@ /* global Blob */ | ||
var parseTorrent = require('parse-torrent') | ||
var path = require('path') | ||
var sha1 = require('simple-sha1') | ||
@@ -17,7 +18,7 @@ var test = require('tape') | ||
var leaves = makeFileShim(fs.readFileSync(__dirname + '/../content/Leaves of Grass by Walt Whitman.epub'), 'Leaves of Grass by Walt Whitman.epub') | ||
var leaves = makeFileShim(fs.readFileSync(path.join(__dirname, '../content/Leaves of Grass by Walt Whitman.epub')), 'Leaves of Grass by Walt Whitman.epub') | ||
var numbers1 = makeFileShim(fs.readFileSync(__dirname + '/../content/numbers/1.txt', 'utf8'), '1.txt') | ||
var numbers2 = makeFileShim(fs.readFileSync(__dirname + '/../content/numbers/2.txt', 'utf8'), '2.txt') | ||
var numbers3 = makeFileShim(fs.readFileSync(__dirname + '/../content/numbers/3.txt', 'utf8'), '3.txt') | ||
var numbers1 = makeFileShim(fs.readFileSync(path.join(__dirname, '../content/numbers/1.txt'), 'utf8'), '1.txt') | ||
var numbers2 = makeFileShim(fs.readFileSync(path.join(__dirname, '../content/numbers/2.txt'), 'utf8'), '2.txt') | ||
var numbers3 = makeFileShim(fs.readFileSync(path.join(__dirname, '../content/numbers/3.txt'), 'utf8'), '3.txt') | ||
@@ -24,0 +25,0 @@ test('create single file torrent', function (t) { |
@@ -6,2 +6,3 @@ /* global Blob */ | ||
var parseTorrent = require('parse-torrent') | ||
var path = require('path') | ||
var sha1 = require('simple-sha1') | ||
@@ -17,5 +18,5 @@ var test = require('tape') | ||
var numbers1 = makeFileShim(fs.readFileSync(__dirname + '/../content/numbers/1.txt', 'utf8'), '1.txt', '/numbers/1.txt') | ||
var numbers2 = makeFileShim(fs.readFileSync(__dirname + '/../content/numbers/2.txt', 'utf8'), '2.txt', '/numbers/2.txt') | ||
var numbers3 = makeFileShim(fs.readFileSync(__dirname + '/../content/numbers/3.txt', 'utf8'), '3.txt', '/numbers/3.txt') | ||
var numbers1 = makeFileShim(fs.readFileSync(path.join(__dirname, '../content/numbers/1.txt'), 'utf8'), '1.txt', '/numbers/1.txt') | ||
var numbers2 = makeFileShim(fs.readFileSync(path.join(__dirname, '../content/numbers/2.txt'), 'utf8'), '2.txt', '/numbers/2.txt') | ||
var numbers3 = makeFileShim(fs.readFileSync(path.join(__dirname, '../content/numbers/3.txt'), 'utf8'), '3.txt', '/numbers/3.txt') | ||
var DSStore = makeFileShim('blah', '.DS_Store', '/numbers/.DS_Store') // this should be ignored | ||
@@ -22,0 +23,0 @@ |
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
444528
946
+ Addedxtend@^4.0.1
- Removeddezalgo@^1.0.1
- Removedasap@2.0.6(transitive)
- Removeddezalgo@1.0.4(transitive)