From d7a88f3ebe314fd2db3507898040b0d5f897183d Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Thu, 8 Oct 2015 22:56:58 -0400 Subject: [PATCH] Updated README.md to include events more events --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 8df1429c..393a8d65 100644 --- a/README.md +++ b/README.md @@ -403,6 +403,35 @@ client.add(magnetUri, function (torrent) { }) ``` +#### `torrent.on('done', function () {})` + +Emitted when all the torrent's files have been downloaded + +Here is a usage example: + +```js +torrent.on('done', function(){ + console.log('torrent finished downloading'); + torrent.files.forEach(function(file){ + // do something with file + }) +}) +``` + +#### `torrent.on('download', function (chunkSize) {})` + +Emitted every time a new chunk of data arrives, it's useful for reporting the current torrent status, for instance: + +```js +torrent.on('download', function(chunkSize){ + console.log('chunk size: ' + chunkSize); + console.log('total downloaded: ' + torrent.downloaded); + console.log('download speed: ' + torrent.downloadSpeed()); + console.log('progress: ' + torrent.progress); + console.log('======'); +}) +``` + #### `torrent.on('wire', function (wire) {})` Emitted whenever a new peer is connected for this torrent. `wire` is an instance of