This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +43
-2
lines changed
Expand file tree Collapse file tree 1 file changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -66,12 +66,53 @@ module.exports = (send) => {
6666 if ( err ) {
6767 return callback ( err )
6868 }
69- // TODO handle the result
69+ if ( result . Cid ) {
70+ return callback ( null , new CID ( result . Cid [ '/' ] ) )
71+ } else {
72+ return callback ( result )
73+ }
7074 } )
7175 }
7276 } ) ,
7377 get : promisify ( ( cid , path , options , callback ) => {
74- // TODO
78+ if ( typeof path === 'function' ) {
79+ callback = path
80+ path = undefined
81+ }
82+
83+ if ( typeof options === 'function' ) {
84+ callback = options
85+ options = { }
86+ }
87+
88+ options = options || { }
89+
90+ if ( CID . isCID ( cid ) ) {
91+ cid = cid . toBaseEncodedString ( )
92+ }
93+
94+ if ( typeof cid === 'string' ) {
95+ const split = cid . split ( '/' )
96+ cid = split [ 0 ]
97+ split . shift ( )
98+
99+ if ( split . length > 0 ) {
100+ path = split . join ( '/' )
101+ } else {
102+ path = '/'
103+ }
104+ }
105+
106+ send ( {
107+ path : 'dag/get' ,
108+ args : cid + '/' + path ,
109+ qs : options
110+ } , ( err , result ) => {
111+ if ( err ) {
112+ return callback ( err )
113+ }
114+ callback ( undefined , { value : result } )
115+ } )
75116 } )
76117 }
77118
You can’t perform that action at this time.
0 commit comments