Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve code examples #538

Merged
merged 4 commits into from Dec 27, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

examples: Use sintel torrent

  • Loading branch information
feross committed Dec 27, 2015
commit 8cff356ce0f6852a80e3b07217ecaa5b1d3e3098
@@ -147,7 +147,7 @@ var client = new WebTorrent()
// When user drops files on the browser, create a new torrent and start seeding it!
dragDrop('body', function (files) {
client.seed(files, function onTorrent (torrent) {
client.seed(files, function (torrent) {
console.log('Client is seeding:', torrent.infoHash)
})
})
@@ -2,8 +2,7 @@ var WebTorrent = require('webtorrent')

var client = new WebTorrent()

// Go to https://instant.io, seed a file and use the magnet uri generated
var magnetUri = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36'
var torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d'

client.add(magnetUri, function (torrent) {
// Got torrent metadata!
@@ -2,11 +2,11 @@ var WebTorrent = require('webtorrent')
var fs = require('fs')

var client = new WebTorrent()
var magnetUri = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36'
var magnetUri = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d'

client.download(magnetUri, function (torrent) {
// Got torrent metadata!
console.log('Torrent info hash:', torrent.infoHash)
console.log('Torrent magnet link:', torrent.magnetURI)

torrent.files.forEach(function (file) {
// Stream each file to the disk
@@ -70,7 +70,7 @@ test('Command line: webtorrent info /path/to/file.torrent', function (t) {
test('Command line: webtorrent info magnet_uri', function (t) {
t.plan(2)

var leavesMagnetURI = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=http%3A%2F%2Ftracker.bittorrent.am%2Fannounce&tr=http%3A%2F%2Ftracker.thepiratebay.org%2Fannounce&tr=udp%3A%2F%2Ffr33domtracker.h33t.com%3A3310%2Fannounce&tr=udp%3A%2F%2Ftracker.ccc.de%3A80&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80'
var leavesMagnetURI = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=http%3A%2F%2Ftracker.bittorrent.am%2Fannounce&tr=http%3A%2F%2Ftracker.thepiratebay.org%2Fannounce&tr=udp%3A%2F%2Ffr33domtracker.h33t.com%3A3310%2Fannounce&tr=udp%3A%2F%2Ftracker.ccc.de%3A80&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80'

cp.exec(CMD + ' info "' + leavesMagnetURI + '"', function (err, data) {
t.error(err)
@@ -95,7 +95,7 @@ test('Command line: webtorrent create /path/to/file', function (t) {
child.stdout.on('end', function () {
var buf = Buffer.concat(chunks)
var parsedTorrent = parseTorrent(new Buffer(buf, 'binary'))
t.deepEqual(parsedTorrent.infoHash, 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36')
t.deepEqual(parsedTorrent.infoHash, '6a9759bffd5c0af65319979fb7832189f4f3c35d')
})
})

@@ -5,7 +5,7 @@ var RarityMap = require('../lib/rarity-map')
var Swarm = require('bittorrent-swarm')
var test = require('tape')

var infoHash = 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36'
var infoHash = '6a9759bffd5c0af65319979fb7832189f4f3c35d'
var peerId1 = '-WW0001-' + hat(48)

test('Rarity map usage', function (t) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.