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

Merged
merged 1 commit 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 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 })))
})
})
}
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 })))
})
})
}