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

Commit 9993217

Browse files
author
Alan Shaw
committed
refactor: return CID instances from block.rm
1 parent 4135c1a commit 9993217

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/block/rm.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const CID = require('cids')
44
const ndjson = require('iterable-ndjson')
55
const configure = require('../lib/configure')
66
const toIterable = require('stream-to-it/source')
7-
const toCamel = require('../lib/object-to-camel')
87

98
module.exports = configure(({ ky }) => {
109
return async function * rm (cid, options) {
@@ -31,7 +30,19 @@ module.exports = configure(({ ky }) => {
3130
})
3231

3332
for await (const removed of ndjson(toIterable(res.body))) {
34-
yield toCamel(removed)
33+
yield toCoreInterface(removed)
3534
}
3635
}
3736
})
37+
38+
function toCoreInterface (removed) {
39+
const out = {
40+
cid: new CID(removed.Hash)
41+
}
42+
43+
if (removed.Error) {
44+
out.error = new Error(removed.Error)
45+
}
46+
47+
return out
48+
}

0 commit comments

Comments
 (0)