diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/.travis.yml b/.travis.yml index f178ec0..c159f6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,3 @@ language: node_js node_js: - - 'node' + - lts/* diff --git a/examples/node-download.js b/examples/node-download.js index bbd9e1f..8739dd7 100644 --- a/examples/node-download.js +++ b/examples/node-download.js @@ -1,24 +1,24 @@ -// var WebTorrent = require('webtorrent-hybrid') -var WebTorrent = require('../index') -var fs = require('fs') +const WebTorrent = require('../index') +const fs = require('fs') -var client = new WebTorrent() +const client = new WebTorrent() -var torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d' +const torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d' console.log('torrentId:\t', torrentId) -client.add(torrentId, function (torrent) { - var files = torrent.files - var length = files.length +client.add(torrentId, torrent => { + const files = torrent.files + let length = files.length // Stream each file to the disk - files.forEach(function (file) { - var source = file.createReadStream() - var destination = fs.createWriteStream(file.name) - source.on('end', function () { + files.forEach(file => { + const source = file.createReadStream() + const destination = fs.createWriteStream(file.name) + source.on('end', () => { console.log('file:\t\t', file.name) // close after all files are saved - if (!--length) process.exit() + length -= 1 + if (!length) process.exit() }).pipe(destination) }) }) diff --git a/examples/node-seed.js b/examples/node-seed.js index e63894e..7848792 100644 --- a/examples/node-seed.js +++ b/examples/node-seed.js @@ -1,13 +1,11 @@ -// var WebTorrent = require('webtorrent-hybrid') -var WebTorrent = require('../index') +const WebTorrent = require('../index') -var client = new WebTorrent() - -var filePath = './node-seed.js' +const client = new WebTorrent() +const filePath = __filename console.log('filePath:', filePath) -client.seed(filePath, function (torrent) { +client.seed(filePath, torrent => { console.log('torrentId (info hash):', torrent.infoHash) // console.log('torrentId (magnet link):', torrent.magnetURI) }) diff --git a/lib/global.js b/lib/global.js index 1f6d163..6673590 100644 --- a/lib/global.js +++ b/lib/global.js @@ -1,13 +1,8 @@ -var createTorrent = require('create-torrent') +const createTorrent = require('create-torrent') +const wrtc = require('wrtc') global.WEBTORRENT_ANNOUNCE = createTorrent.announceList - .map(function (arr) { - return arr[0] - }) - .filter(function (url) { - return url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0 - }) - -var wrtc = require('wrtc') + .map(arr => arr[0]) + .filter(url => url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0) global.WRTC = wrtc diff --git a/package.json b/package.json index 5088d6c..7514a97 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "standard": "*" }, "engines": { - "node": ">=4" + "node": ">=6" }, "homepage": "http://webtorrent.io", "keywords": [