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

fix: return iterables from pin add and pin rm #1240

Closed
wants to merge 5 commits into from
Closed
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"aegir": "^20.4.1",
"async": "^3.1.0",
"browser-process-platform": "~0.1.1",
"go-ipfs-dep": "^0.4.23-3",
"interface-ipfs-core": "^0.131.7",
"go-ipfs-dep": "0.4.23-3",
"interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#store-pins-in-datastore",
"ipfsd-ctl": "^3.0.0",
"it-all": "^1.0.1",
"it-concat": "^1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/pin/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const CID = require('cids')
const configure = require('../lib/configure')

module.exports = configure(({ ky }) => {
return async (paths, options) => {
return async function * (paths, options) {
paths = Array.isArray(paths) ? paths : [paths]
options = options || {}

Expand All @@ -19,6 +19,6 @@ module.exports = configure(({ ky }) => {
searchParams
}).json()

return (res.Pins || []).map(cid => ({ cid: new CID(cid) }))
yield * (res.Pins || []).map(cid => ({ cid: new CID(cid) }))
}
})
7 changes: 4 additions & 3 deletions src/pin/rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ const CID = require('cids')
const configure = require('../lib/configure')

module.exports = configure(({ ky }) => {
return async (path, options) => {
return async function * (paths, options) {
paths = Array.isArray(paths) ? paths : [paths]
options = options || {}

const searchParams = new URLSearchParams(options.searchParams)
searchParams.set('arg', `${path}`)
paths.forEach(path => searchParams.append('arg', `${path}`))
if (options.recursive != null) searchParams.set('recursive', options.recursive)

const res = await ky.post('pin/rm', {
Expand All @@ -18,6 +19,6 @@ module.exports = configure(({ ky }) => {
searchParams
}).json()

return (res.Pins || []).map(cid => ({ cid: new CID(cid) }))
yield * (res.Pins || []).map(cid => ({ cid: new CID(cid) }))
}
})