diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-05-02 16:23:42 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-05-02 16:23:42 +0300 |
commit | 179bcd086995c5ea8379608dae73dff8768b4545 (patch) | |
tree | fed16513d8155bc684766b631b320a81db8d6ed3 /docs | |
parent | f13fcc76963d8ba5481a0dc94b63c61c35face46 (diff) | |
parent | b28e8d637dcbddacdc3981adb524dd9d41f9c431 (diff) |
Merge pull request #750 from feross/api-improvement
API improve
Diffstat (limited to 'docs')
-rw-r--r-- | docs/api.md | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/docs/api.md b/docs/api.md index fa7803a..b745d94 100644 --- a/docs/api.md +++ b/docs/api.md @@ -352,21 +352,6 @@ listen to this event, but it may aid in debugging. Emitted when the torrent encounters a fatal error. The torrent is automatically destroyed and removed from the client when this occurs. -## `torrent.on('infoHash', function () {})` - -Emitted when the info hash of the torrent has been determined. - -## `torrent.on('metadata', function () {})` - -Emitted when the metadata of the torrent has been determined. This includes the full -contents of the .torrent file, including list of files, torrent length, piece hashes, -piece length, etc. - -## `torrent.on('ready', function () {})` - -Emitted when the torrent is ready to be used (i.e. metadata is available and store is -ready). - ## `torrent.on('done', function () {})` Emitted when all the torrent files have been downloaded. @@ -396,6 +381,20 @@ torrent.on('download', function(chunkSize){ }) ``` +## `torrent.on('upload', function (chunkSize) {})` + +Emitted every time a new chunk of data is sent, it's useful for reporting the current torrent status, for instance: + +```js +torrent.on('uploaded', function(chunkSize){ + console.log('chunk size: ' + chunkSize); + console.log('total uploaded: ' + torrent.uploaded); + console.log('upload speed: ' + torrent.uploadSpeed); + 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 @@ -418,6 +417,21 @@ See the `bittorrent-protocol` [extension api docs](https://github.com/feross/bittorrent-protocol#extension-api) for more information on how to define a protocol extension. +## `torrent.on('infoHash', function () {})` + +Emitted when the info hash of the torrent has been determined. + +## `torrent.on('metadata', function () {})` + +Emitted when the metadata of the torrent has been determined. This includes the full +contents of the .torrent file, including list of files, torrent length, piece hashes, +piece length, etc. + +## `torrent.on('ready', function () {})` + +Emitted when the torrent is ready to be used (i.e. metadata is available and store is +ready). + # File API ## `file.name` |