@@ -229,14 +229,14 @@ class FetchBlobResponse {
229229 path : ( ) => string | null ;
230230 type : 'base64' | 'path' | 'utf8' ;
231231 data : any ;
232- blob : ( contentType :string , sliceSize :number ) => null ;
233- text : ( ) => string ;
232+ blob : ( contentType :string , sliceSize :number ) => Promise < Blob > ;
233+ text : ( ) => string | Promise < any > ;
234234 json : ( ) => any ;
235235 base64 : ( ) => any ;
236236 flush : ( ) => void ;
237237 respInfo : RNFetchBlobResponseInfo ;
238238 session : ( name :string ) => RNFetchBlobSession | null ;
239- readFile : ( encode : 'base64' | 'utf8' | 'ascii' ) => ?Promise ;
239+ readFile : ( encode : 'base64' | 'utf8' | 'ascii' ) => ?Promise < any > ;
240240 readStream : (
241241 encode : 'utf8' | 'ascii' | 'base64' ,
242242 ) => RNFetchBlobStream | null ;
@@ -275,18 +275,15 @@ class FetchBlobResponse {
275275 * Convert result to text.
276276 * @return {string } Decoded base64 string.
277277 */
278- this . text = ( ) :string => {
278+ this . text = ( ) :string | Promise < any > => {
279279 let res = this . data
280280 switch ( this . type ) {
281281 case 'base64' :
282282 return base64 . decode ( this . data )
283- break
284283 case 'path' :
285284 return fs . readFile ( this . data , 'base64' ) . then ( ( b64 ) => Promise . resolve ( base64 . decode ( b64 ) ) )
286- break
287285 default :
288286 return this . data
289- break
290287 }
291288 }
292289 /**
@@ -297,31 +294,25 @@ class FetchBlobResponse {
297294 switch ( this . type ) {
298295 case 'base64' :
299296 return JSON . parse ( base64 . decode ( this . data ) )
300- break
301297 case 'path' :
302298 return fs . readFile ( this . data , 'utf8' )
303299 . then ( ( text ) => Promise . resolve ( JSON . parse ( text ) ) )
304- break
305300 default :
306301 return JSON . parse ( this . data )
307- break
308302 }
309303 }
310304 /**
311305 * Return BASE64 string directly.
312306 * @return {string } BASE64 string of response body.
313307 */
314- this . base64 = ( ) :string => {
308+ this . base64 = ( ) :string | Promise < any > => {
315309 switch ( this . type ) {
316310 case 'base64' :
317311 return this . data
318- break
319312 case 'path' :
320313 return fs . readFile ( this . data , 'base64' )
321- break
322314 default:
323315 return base64 . encode ( this . data )
324- break
325316 }
326317 }
327318 /**
@@ -376,7 +367,6 @@ class FetchBlobResponse {
376367 this . readFile = ( encode : 'base64' | 'utf8' | 'ascii' ) => {
377368 if ( this . type === 'path' ) {
378369 encode = encode || 'utf8'
379-
380370 return readFile ( this . data , encode )
381371 }
382372 else {
0 commit comments