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

Commit

Permalink
feat: update pin API to match interface-ipfs-core
Browse files Browse the repository at this point in the history
* Make pin interface respect interface-ipfs-core API (#602)

* chore: fix linting

* chore: update dep
  • Loading branch information
daviddias authored Oct 22, 2017
1 parent 1ed6a34 commit 9102643
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
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 })))
})
})
}

0 comments on commit 9102643

Please sign in to comment.