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

Commit 9102643

Browse files
authored
feat: update pin API to match interface-ipfs-core
* Make pin interface respect interface-ipfs-core API (#602) * chore: fix linting * chore: update dep
1 parent 1ed6a34 commit 9102643

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"dirty-chai": "^2.0.1",
6666
"eslint-plugin-react": "^7.4.0",
6767
"gulp": "^3.9.1",
68-
"interface-ipfs-core": "~0.32.1",
68+
"interface-ipfs-core": "~0.33.0",
6969
"hapi": "^16.6.2",
7070
"ipfsd-ctl": "~0.24.0",
7171
"pre-commit": "^1.2.2",

Diff for: src/pin/add.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = (send) => {
1616
if (err) {
1717
return callback(err)
1818
}
19-
callback(null, res.Pins)
19+
callback(null, res.Pins.map((hash) => ({ hash: hash })))
2020
})
2121
})
2222
}

Diff for: src/pin/ls.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
'use strict'
22

33
const promisify = require('promisify-es6')
4+
const _ = require('lodash')
45

56
module.exports = (send) => {
67
return promisify((hash, opts, callback) => {
8+
if (typeof hash === 'function') {
9+
callback = hash
10+
opts = null
11+
hash = null
12+
}
713
if (typeof opts === 'function') {
814
callback = opts
9-
opts = {}
1015
}
11-
12-
if (typeof hash === 'object') {
16+
if (hash && hash.type) {
1317
opts = hash
14-
hash = undefined
15-
}
16-
17-
if (typeof hash === 'function') {
18-
callback = hash
19-
hash = undefined
20-
opts = {}
18+
hash = null
19+
} else {
20+
opts = null
2121
}
2222

2323
send({
@@ -28,7 +28,9 @@ module.exports = (send) => {
2828
if (err) {
2929
return callback(err)
3030
}
31-
callback(null, res.Keys)
31+
callback(null, _.keys(res.Keys).map(hash => (
32+
{ hash, type: res.Keys[hash].Type }
33+
)))
3234
})
3335
})
3436
}

Diff for: src/pin/rm.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = (send) => {
1616
if (err) {
1717
return callback(err)
1818
}
19-
callback(null, res.Pins)
19+
callback(null, res.Pins.map((hash) => ({ hash: hash })))
2020
})
2121
})
2222
}

0 commit comments

Comments
 (0)