Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoRBaquero authored Dec 11, 2018
2 parents d2437ad + c0e5153 commit 54618f0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: node_js
node_js:
- 'node'
- lts/*
26 changes: 13 additions & 13 deletions examples/node-download.js
Original file line number Diff line number Diff line change
@@ -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)
})
})
10 changes: 4 additions & 6 deletions examples/node-seed.js
Original file line number Diff line number Diff line change
@@ -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)
})
13 changes: 4 additions & 9 deletions lib/global.js
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"standard": "*"
},
"engines": {
"node": ">=4"
"node": ">=6"
},
"homepage": "http://webtorrent.io",
"keywords": [
Expand Down

0 comments on commit 54618f0

Please sign in to comment.