This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree 3 files changed +51
-3
lines changed
3 files changed +51
-3
lines changed Original file line number Diff line number Diff line change 107
107
"browser-process-platform" : " ~0.1.1" ,
108
108
"cross-env" : " ^6.0.0" ,
109
109
"go-ipfs-dep" : " ^0.4.22" ,
110
- "interface-ipfs-core" : " ^0.117.0 " ,
110
+ "interface-ipfs-core" : " ^0.117.2 " ,
111
111
"ipfsd-ctl" : " ^0.47.1" ,
112
112
"nock" : " ^11.3.2" ,
113
113
"stream-equal" : " ^1.1.1"
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
+ const nodeify = require ( 'promise-nodeify' )
3
4
const moduleConfig = require ( '../utils/module-config' )
5
+ const { collectify } = require ( '../lib/converters' )
4
6
5
- module . exports = ( arg ) => {
7
+ module . exports = ( arg , config ) => {
6
8
const send = moduleConfig ( arg )
9
+ const rm = require ( './rm-async-iterator' ) ( config )
7
10
8
11
return {
9
12
get : require ( './get' ) ( send ) ,
10
13
stat : require ( './stat' ) ( send ) ,
11
- put : require ( './put' ) ( send )
14
+ put : require ( './put' ) ( send ) ,
15
+ rm : ( input , options , callback ) => {
16
+ if ( typeof options === 'function' ) {
17
+ callback = options
18
+ options = { }
19
+ }
20
+ return nodeify ( collectify ( rm ) ( input , options ) , callback )
21
+ } ,
22
+ _rmAsyncIterator : rm
12
23
}
13
24
}
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ const CID = require ( 'cids' )
4
+ const ndjson = require ( 'iterable-ndjson' )
5
+ const configure = require ( '../lib/configure' )
6
+ const toIterable = require ( '../lib/stream-to-iterable' )
7
+ const toCamel = require ( '../lib/object-to-camel' )
8
+
9
+ module . exports = configure ( ( { ky } ) => {
10
+ return async function * removeBlock ( cid , options ) {
11
+ options = options || { }
12
+
13
+ if ( ! Array . isArray ( cid ) ) {
14
+ cid = [ cid ]
15
+ }
16
+
17
+ const searchParams = new URLSearchParams ( )
18
+ searchParams . set ( 'stream-channels' , true )
19
+ searchParams . set ( 'force' , options . force || false )
20
+ searchParams . set ( 'quiet' , options . quiet || false )
21
+
22
+ cid . forEach ( cid => {
23
+ searchParams . append ( 'arg' , new CID ( cid ) . toString ( ) )
24
+ } )
25
+
26
+ const res = await ky . post ( 'block/rm' , {
27
+ timeout : options . timeout ,
28
+ signal : options . signal ,
29
+ headers : options . headers ,
30
+ searchParams
31
+ } )
32
+
33
+ for await ( const removed of ndjson ( toIterable ( res . body ) ) ) {
34
+ yield toCamel ( removed )
35
+ }
36
+ }
37
+ } )
You can’t perform that action at this time.
0 commit comments