Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 69d5e1e

Browse files
docs(api): more
1 parent 33729d1 commit 69d5e1e

File tree

4 files changed

+66
-33
lines changed

4 files changed

+66
-33
lines changed

src/api/add.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ module.exports = (send) => {
1010
*
1111
* @alias add
1212
* @method
13-
* @param {(Buffer|Stream|Array)} files - The content to add.
14-
* @param {function=} callback
15-
* @returns {Promise}
13+
* @param {(Buffer|Stream|Array<Buffer|Stream>)} files - The content to add.
14+
* @param {function(Error, {hash: string})} [callback]
15+
* @returns {Promise<{hash: string}>|undefined}
1616
*
1717
* @memberof Api#
1818
*

src/api/bitswap.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,57 @@ module.exports = (send) => {
77
/**
88
* Show blocks currently on the wantlist.
99
*
10+
* Print out all blocks currently on the bitswap wantlist for the local peer.
11+
*
1012
* @alias bitswap.wantlist
1113
* @method
12-
* @param {Function} [callback]
14+
* @param {function(Error, Array<string>)} [callback]
1315
*
14-
* @returns {Promise}
16+
* @returns {Promise<Array<string>>|undefined}
1517
* @memberof Api#
1618
*/
1719
wantlist: promisify((callback) => {
1820
send({
1921
path: 'bitswap/wantlist'
2022
}, callback)
2123
}),
24+
2225
/**
2326
* Show some diagnostic information on the bitswap agent.
2427
*
2528
* @alias bitswap.stat
2629
* @method
27-
* @param {Function} [callback]
30+
* @param {function(Error, Object)} [callback]
2831
*
29-
* @returns {Promise}
32+
* @returns {Promise<Object>|undefined}
3033
* @memberof Api#
3134
*/
3235
stat: promisify((callback) => {
3336
send({
3437
path: 'bitswap/stat'
3538
}, callback)
3639
}),
40+
3741
/**
3842
* Remove a given block from your wantlist.
3943
*
4044
* @alias bitswap.unwant
4145
* @method
42-
* @param {*} args
43-
* @param {Object} opts
44-
* @param {Function} [callback]
46+
* @param {string|Array<string>} key - The `base58` encoded multihashes of the blocks to unwant.
47+
* @param {Object} [opts={}]
48+
* @param {function(Error)} [callback]
4549
*
46-
* @returns {Promise}
50+
* @returns {Promise<undefined>|undefined}
4751
* @memberof Api#
4852
*/
49-
unwant: promisify((args, opts, callback) => {
53+
unwant: promisify((key, opts, callback) => {
5054
if (typeof (opts) === 'function') {
5155
callback = opts
5256
opts = {}
5357
}
5458
send({
5559
path: 'bitswap/unwant',
56-
args: args,
60+
args: key,
5761
qs: opts
5862
}, callback)
5963
})

src/api/block.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ const CID = require('cids')
99
module.exports = (send) => {
1010
return {
1111
/**
12+
* Get a raw IPFS block
13+
*
1214
* @alias block.get
1315
* @method
14-
* @returns {Promise|undefined}
16+
* @param {CID|string} args - the multihash or CID of the block.
17+
* @param {Object} [opts={}]
18+
* @param {function(Error, Block)} [callback]
19+
* @returns {Promise<Block>|undefined}
1520
* @memberof Api#
1621
*/
1722
get: promisify((args, opts, callback) => {
@@ -46,15 +51,20 @@ module.exports = (send) => {
4651
}),
4752

4853
/**
54+
* Print information of a raw IPFS block.
55+
*
4956
* @alias block.stat
5057
* @method
51-
* @returns {Promise|undefined}
58+
* @param {CID|string} key - the `base58` multihash or CID of the block.
59+
* @param {Object} [opts={}]
60+
* @param {function(Error, {key: string, size: string})} [callback]
61+
* @returns {Promise<{key: string, size: string}>|undefined}
5262
* @memberof Api#
5363
*/
54-
stat: promisify((args, opts, callback) => {
64+
stat: promisify((key, opts, callback) => {
5565
// TODO this needs to be adjusted with the new go-ipfs http-api
56-
if (args && CID.isCID(args)) {
57-
args = multihash.toB58String(args.multihash)
66+
if (key && CID.isCID(key)) {
67+
key = multihash.toB58String(key.multihash)
5868
}
5969

6070
if (typeof (opts) === 'function') {
@@ -63,7 +73,7 @@ module.exports = (send) => {
6373
}
6474
return send({
6575
path: 'block/stat',
66-
args: args,
76+
args: key,
6777
qs: opts
6878
}, (err, stats) => {
6979
if (err) {
@@ -77,9 +87,15 @@ module.exports = (send) => {
7787
}),
7888

7989
/**
90+
* Store input as an IPFS block.
91+
*
8092
* @alias block.put
8193
* @method
82-
* @returns {Promise|undefined}
94+
* @param {Object} block - The block to create.
95+
* @param {Buffer} block.data - The data to be stored as an IPFS block.
96+
* @param {CID} [cid]
97+
* @param {function(Error, Block)} [callback]
98+
* @returns {Promise<Block>|undefined}
8399
* @memberof Api#
84100
*/
85101
put: promisify((block, cid, callback) => {

src/api/bootstrap.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ const promisify = require('promisify-es6')
55
module.exports = (send) => {
66
return {
77
/**
8+
* Add peers to the bootstrap list.
89
* @alias bootstrap.add
910
* @method
10-
* @returns {Promise|undefined}
11+
* @param {string|Array<string>} peers - A list of peers to add to the bootstrap list (in the format `'<multiaddr>/<peerID>'`)
12+
* @param {Object} [opts={}]
13+
* @param {function(Error)} [callback]
14+
* @returns {Promise<undefined>|undefined}
1115
* @memberof Api#
1216
*/
13-
add: promisify((args, opts, callback) => {
17+
add: promisify((peers, opts, callback) => {
1418
if (typeof opts === 'function' &&
1519
!callback) {
1620
callback = opts
@@ -25,25 +29,30 @@ module.exports = (send) => {
2529
opts = {}
2630
}
2731

28-
if (args && typeof args === 'object') {
29-
opts = args
30-
args = undefined
32+
if (peers && typeof peers === 'object') {
33+
opts = peers
34+
peers = undefined
3135
}
3236

3337
send({
3438
path: 'bootstrap/add',
35-
args: args,
39+
args: peers,
3640
qs: opts
3741
}, callback)
3842
}),
3943

4044
/**
45+
* Remove peers from the bootstrap list.
46+
*
4147
* @alias bootstrap.rm
4248
* @method
43-
* @returns {Promise|undefined}
49+
* @param {string|Array<string>} peers - The peers to remove from the bootstrap list
50+
* @param {Object} [opts={}]
51+
* @param {function(Error)} [callback]
52+
* @returns {Promise<undefined>|undefined}
4453
* @memberof Api#
4554
*/
46-
rm: promisify((args, opts, callback) => {
55+
rm: promisify((peers, opts, callback) => {
4756
if (typeof opts === 'function' &&
4857
!callback) {
4958
callback = opts
@@ -58,22 +67,26 @@ module.exports = (send) => {
5867
opts = {}
5968
}
6069

61-
if (args && typeof args === 'object') {
62-
opts = args
63-
args = undefined
70+
if (peers && typeof peers === 'object') {
71+
opts = peers
72+
peers = undefined
6473
}
6574

6675
send({
6776
path: 'bootstrap/rm',
68-
args: args,
77+
args: peers,
6978
qs: opts
7079
}, callback)
7180
}),
7281

7382
/**
83+
* Show peers in the bootstrap list.
84+
*
7485
* @alias bootstrap.list
7586
* @method
76-
* @returns {Promise|undefined}
87+
* @param {Object} [opts={}]
88+
* @param {function(Error, Array<string>)} [callback]
89+
* @returns {Promise<Array<string>|undefined}
7790
* @memberof Api#
7891
*/
7992
list: promisify((opts, callback) => {

0 commit comments

Comments
 (0)