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

Commit f213215

Browse files
committed
feat: gc
1 parent 57af616 commit f213215

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/repo/gc.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
'use strict'
22

33
const promisify = require('promisify-es6')
4+
const streamToValueWithTransformer = require('../utils/stream-to-value-with-transformer')
5+
6+
const transform = function (res, callback) {
7+
callback(null, res.map(r => ({
8+
err: r.Err,
9+
cid: (r.Key || {})['/']
10+
})))
11+
}
412

513
module.exports = (send) => {
614
return promisify((opts, callback) => {
715
if (typeof (opts) === 'function') {
816
callback = opts
917
opts = {}
1018
}
11-
send({
19+
20+
const request = {
1221
path: 'repo/gc',
1322
qs: opts
14-
}, callback)
23+
}
24+
send(request, (err, result) => {
25+
if (err) {
26+
return callback(err)
27+
}
28+
29+
streamToValueWithTransformer(result, transform, callback)
30+
})
1531
})
1632
}

0 commit comments

Comments
 (0)