This repository was archived by the owner on Mar 16, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export default class RNFetchBlobReadStream {
27
27
28
28
// register for file stream event
29
29
let subscription = emitter . addListener ( `RNFetchBlobStream+${ this . path } ` , ( e ) => {
30
-
30
+
31
31
let { event, detail} = e
32
32
if ( this . _onData && event === 'data' )
33
33
this . _onData ( detail )
@@ -59,7 +59,7 @@ export default class RNFetchBlobReadStream {
59
59
onData ( fn ) {
60
60
if ( this . encoding . toLowerCase ( ) === 'ascii' )
61
61
this . _onData = ( data ) => {
62
- fn ( JSON . parse ( data ) )
62
+ fn ( data )
63
63
}
64
64
else
65
65
this . _onData = fn
Original file line number Diff line number Diff line change @@ -134,10 +134,14 @@ function mkdir(path:string):Promise {
134
134
* @return {Promise<Array<number> | string> }
135
135
*/
136
136
function readFile ( path :string , encoding :string , bufferSize :number ) :Promise < any > {
137
+ if ( typeof path !== 'string' )
138
+ return Promise . reject ( 'Invalid argument "path" ' )
137
139
return RNFetchBlob . readFile ( path , encoding )
138
140
}
139
141
140
142
function writeFile ( path :string , encoding :string , data :string | Array < number > ) :Promise {
143
+ if ( typeof path !== 'string' )
144
+ return Promise . reject ( 'Invalid argument "path" ' )
141
145
if ( encoding . toLocaleLowerCase ( ) === 'ascii' ) {
142
146
if ( ! Array . isArray ( data ) )
143
147
Promise . reject ( `Expected "data" is an Array when encoding is "ascii", however got ${ typeof data } ` )
@@ -286,6 +290,8 @@ export default {
286
290
mv,
287
291
cp,
288
292
writeStream,
293
+ writeFile,
294
+ readFile,
289
295
exists,
290
296
createFile,
291
297
isDir,
You can’t perform that action at this time.
0 commit comments