From f008b63081f8ba58eb89b1be7a6799b13709c5d1 Mon Sep 17 00:00:00 2001 From: Gabriel Juchault Date: Thu, 15 Aug 2019 12:15:20 +0200 Subject: [PATCH 1/2] docs(api): add documentation for announce, maxWebConns, ready, paused, done, pieces, created, createdBy, comment, lenght, pieceLength and lastPieceLength --- docs/api.md | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/docs/api.md b/docs/api.md index ca3a4f11..5634b159 100644 --- a/docs/api.md +++ b/docs/api.md @@ -221,11 +221,28 @@ Magnet URI of the torrent (string). `.torrent` file of the torrent (Blob URL). +## `torrent.announce[...]` + +Array of all tracker servers. Each announce is an URL (string). + ## `torrent.files[...]` Array of all files in the torrent. See documentation for `File` below to learn what methods/properties files have. +## `torrent.pieces[...]` + +Array of all pieces in the torrent. See documentation for `Piece` below to learn what +properties pieces have. Some pieces can be null. + +## `torrent.pieceLength` + +Length in bytes of every piece but the last one. + +## `torrent.lastPieceLength` + +Length in bytes of the last piece (<= of `torrent.pieceLength`). + ## `torrent.timeRemaining` Time remaining for download to complete (in milliseconds). @@ -262,10 +279,53 @@ Torrent "seed ratio" (uploaded / downloaded). Number of peers in the torrent swarm. +## `torrent.maxWebConns` + +Max number of simultaneous connections per web seed, as passed in the options. + ## `torrent.path` Torrent download location. +## `torrent.ready` + +True when the torrent is ready to be used (i.e. metadata is available and store is +ready). + +## `torrent.paused` + +True when the torrent has stopped connecting to new peers. Note that this does +not pause new incoming connections, nor does it pause the streams of existing +connections or their wires. + +## `torrent.done` + +True when all the torrent files have been downloaded. + +## `torrent.length` + +Sum of the files length (in bytes). + +## `torrent.pieceLength` + +Length in bytes of all the pieces but the last one. + +## `torrent.lastPieceLength` + +Length in bytes of the last piece (<= `torrent.pieceLength`) + +## `torrent.created` + +Date of creation of the torrent (as a [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object). + +## `torrent.createdBy` + +Author of the torrent (string). + +## `torrent.comment` + +A comment optionnaly set by the author (string). + ## `torrent.destroy([callback])` Alias for `client.remove(torrent)`. If `callback` is provided, it will be called when @@ -637,3 +697,13 @@ file.getBlobURL(function (err, url) { document.body.appendChild(a) }) ``` + +# Piece API + +## `piece.length` + +Piece length (in bytes). *Example: 12345* + +## `piece.missing` + +Piece missing length (in bytes). *Example: 100* From 780e9e4ebc8360315d4cafcc9a1ac7170737fd12 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 15 Aug 2019 13:07:10 -0700 Subject: [PATCH 2/2] doc: Remove duplicated API docs --- docs/api.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docs/api.md b/docs/api.md index 5634b159..843e5afa 100644 --- a/docs/api.md +++ b/docs/api.md @@ -306,14 +306,6 @@ True when all the torrent files have been downloaded. Sum of the files length (in bytes). -## `torrent.pieceLength` - -Length in bytes of all the pieces but the last one. - -## `torrent.lastPieceLength` - -Length in bytes of the last piece (<= `torrent.pieceLength`) - ## `torrent.created` Date of creation of the torrent (as a [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object).