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

Make pin interface respect interface-ipfs-core API (#602) #613

Merged
merged 3 commits into from
Oct 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"dirty-chai": "^2.0.1",
"eslint-plugin-react": "^7.4.0",
"gulp": "^3.9.1",
"interface-ipfs-core": "~0.32.1",
"interface-ipfs-core": "~0.33.0",
"hapi": "^16.6.2",
"ipfsd-ctl": "~0.24.0",
"pre-commit": "^1.2.2",
Expand Down
2 changes: 1 addition & 1 deletion src/pin/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = (send) => {
if (err) {
return callback(err)
}
callback(null, res.Pins)
callback(null, res.Pins.map((hash) => ({ hash: hash })))
})
})
}
24 changes: 13 additions & 11 deletions src/pin/ls.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
'use strict'

const promisify = require('promisify-es6')
const _ = require('lodash')

module.exports = (send) => {
return promisify((hash, opts, callback) => {
if (typeof hash === 'function') {
callback = hash
opts = null
hash = null
}
if (typeof opts === 'function') {
callback = opts
opts = {}
}

if (typeof hash === 'object') {
if (hash && hash.type) {
opts = hash
hash = undefined
}

if (typeof hash === 'function') {
callback = hash
hash = undefined
opts = {}
hash = null
} else {
opts = null
}

send({
Expand All @@ -28,7 +28,9 @@ module.exports = (send) => {
if (err) {
return callback(err)
}
callback(null, res.Keys)
callback(null, _.keys(res.Keys).map(hash => (
{ hash, type: res.Keys[hash].Type }
)))
})
})
}
2 changes: 1 addition & 1 deletion src/pin/rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = (send) => {
if (err) {
return callback(err)
}
callback(null, res.Pins)
callback(null, res.Pins.map((hash) => ({ hash: hash })))
})
})
}