Merge pull request #14479 from tlaziuk/webtorrent

[webtorrent] add undocumented properties
This commit is contained in:
Arthur Ozga
2017-02-09 12:58:30 -08:00
committed by GitHub
2 changed files with 15 additions and 12 deletions
+15 -11
View File
@@ -5,9 +5,10 @@
/// <reference types="node" />
import * as ParseTorrent from 'parse-torrent';
import * as SimplePeer from 'simple-peer';
import * as http from 'http';
import { Instance as ParseTorrent } from 'parse-torrent';
import { Instance as SimplePeer } from 'simple-peer';
import { RequestOptions, Server } from 'http';
import { Wire } from 'bittorrent-protocol';
declare const WebTorrent: WebTorrent.WebTorrent;
@@ -32,14 +33,15 @@ declare namespace WebTorrent {
maxWebConns?: number;
path?: string;
store?: (chunkLength: number, storeOpts: { length: number, files: File[], torrent: Torrent, }) => any;
name?: string;
}
export interface Instance extends NodeJS.EventEmitter {
on(event: 'torrent', callback: (torrent: Torrent) => void): this;
on(event: 'error', callback: (err: Error | string) => void): this;
add(torrent: string | Buffer | ParseTorrent.Instance, opts?: TorrentOptions, cb?: (torrent: Torrent) => any): Torrent;
add(torrent: string | Buffer | ParseTorrent.Instance, cb?: (torrent: Torrent) => any): Torrent;
add(torrent: string | Buffer | ParseTorrent, opts?: TorrentOptions, cb?: (torrent: Torrent) => any): Torrent;
add(torrent: string | Buffer | ParseTorrent, cb?: (torrent: Torrent) => any): Torrent;
seed(input: string | string[] | File | File[] | FileList | Buffer | Buffer[] | NodeJS.ReadableStream | NodeJS.ReadableStream[], opts?: TorrentOptions, cb?: (torrent: Torrent) => any): Torrent;
seed(input: string | string[] | File | File[] | FileList | Buffer | Buffer[] | NodeJS.ReadableStream | NodeJS.ReadableStream[], cb?: (torrent: Torrent) => any): Torrent;
@@ -92,19 +94,23 @@ declare namespace WebTorrent {
readonly path: string;
readonly ready: boolean;
readonly name: string;
destroy(cb?: (err: Error | string) => void): void;
addPeer(peer: string | SimplePeer.Instance): boolean;
addPeer(peer: string | SimplePeer): boolean;
addWebSeed(url: string): void;
removePeer(peer: string | SimplePeer.Instance): void;
removePeer(peer: string | SimplePeer): void;
select(start: number, end: number, priority?: number, notify?: () => void): void;
deselect(start: number, end: number, priority: number): void;
createServer(opts?: http.RequestOptions): http.Server;
createServer(opts?: RequestOptions): Server;
pause(): void;
@@ -112,13 +118,11 @@ declare namespace WebTorrent {
on(event: 'infoHash' | 'metadata' | 'ready' | 'done', callback: () => void): this;
on(event: 'warning' | 'error', callback: (err: Error | string) => void): this;
on(event: 'download' | 'upload', callback: (bytes: number) => void): this;
// TODO: wire is a bittorrent-protocol instance
on(event: 'wire', callback: (wire: any, addr?: string) => void): this;
on(event: 'wire', callback: (wire: Wire, addr?: string) => void): this;
on(event: 'noPeers', callback: (announceType: 'tracker' | 'dht') => void): this;
}
-1
View File
@@ -52,7 +52,6 @@ client.add(magnetURI, {}, function(torrent) {
torrent.on('wire', function(wire, addr) {
console.log('connected to peer with address ' + addr);
wire.use();
});
});