This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +51
-3
lines changed Expand file tree Collapse file tree 3 files changed +51
-3
lines changed Original file line number Diff line number Diff line change 107107 "browser-process-platform" : " ~0.1.1" ,
108108 "cross-env" : " ^6.0.0" ,
109109 "go-ipfs-dep" : " ^0.4.22" ,
110- "interface-ipfs-core" : " ^0.117.0 " ,
110+ "interface-ipfs-core" : " ^0.117.2 " ,
111111 "ipfsd-ctl" : " ^0.47.1" ,
112112 "nock" : " ^11.3.2" ,
113113 "stream-equal" : " ^1.1.1"
Original file line number Diff line number Diff line change 11'use strict'
22
3+ const nodeify = require ( 'promise-nodeify' )
34const moduleConfig = require ( '../utils/module-config' )
5+ const { collectify } = require ( '../lib/converters' )
46
5- module . exports = ( arg ) => {
7+ module . exports = ( arg , config ) => {
68 const send = moduleConfig ( arg )
9+ const rm = require ( './rm-async-iterator' ) ( config )
710
811 return {
912 get : require ( './get' ) ( send ) ,
1013 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
1223 }
1324}
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