@@ -6,11 +6,11 @@ import {
66 NativeModules ,
77 DeviceEventEmitter ,
88 NativeAppEventEmitter ,
9- } from 'react-native'
10- import UUID from '../utils/uuid'
9+ } from 'react-native' ;
10+ import UUID from '../utils/uuid' ;
1111
12- const ReactNativeBlobUtil = NativeModules . ReactNativeBlobUtil
13- const emitter = DeviceEventEmitter
12+ const ReactNativeBlobUtil = NativeModules . ReactNativeBlobUtil ;
13+ const emitter = DeviceEventEmitter ;
1414
1515export default class ReactNativeBlobUtilReadStream {
1616
@@ -22,61 +22,61 @@ export default class ReactNativeBlobUtilReadStream {
2222
2323 constructor ( path :string , encoding :string , bufferSize ?:?number , tick :number ) {
2424 if ( ! path )
25- throw Error ( 'ReactNativeBlobUtil could not open file stream with empty `path`' )
26- this . encoding = encoding || 'utf8'
27- this . bufferSize = bufferSize
28- this . path = path
29- this . closed = false
30- this . tick = tick
31- this . _onData = ( ) => { }
32- this . _onEnd = ( ) => { }
33- this . _onError = ( ) => { }
34- this . streamId = 'RNFBRS' + UUID ( )
25+ throw Error ( 'ReactNativeBlobUtil could not open file stream with empty `path`' ) ;
26+ this . encoding = encoding || 'utf8' ;
27+ this . bufferSize = bufferSize ;
28+ this . path = path ;
29+ this . closed = false ;
30+ this . tick = tick ;
31+ this . _onData = ( ) => { } ;
32+ this . _onEnd = ( ) => { } ;
33+ this . _onError = ( ) => { } ;
34+ this . streamId = 'RNFBRS' + UUID ( ) ;
3535
3636 // register for file stream event
3737 let subscription = emitter . addListener ( this . streamId , ( e ) => {
38- let { event, code, detail} = e
38+ let { event, code, detail} = e ;
3939 if ( this . _onData && event === 'data' ) {
40- this . _onData ( detail )
41- return
40+ this . _onData ( detail ) ;
41+ return ;
4242 }
4343 else if ( this . _onEnd && event === 'end' ) {
44- this . _onEnd ( detail )
44+ this . _onEnd ( detail ) ;
4545 }
4646 else {
47- const err = new Error ( detail )
48- err . code = code || 'EUNSPECIFIED'
47+ const err = new Error ( detail ) ;
48+ err . code = code || 'EUNSPECIFIED' ;
4949 if ( this . _onError )
50- this . _onError ( err )
50+ this . _onError ( err ) ;
5151 else
52- throw err
52+ throw err ;
5353 }
5454 // when stream closed or error, remove event handler
5555 if ( event === 'error' || event === 'end' ) {
56- subscription . remove ( )
57- this . closed = true
56+ subscription . remove ( ) ;
57+ this . closed = true ;
5858 }
59- } )
59+ } ) ;
6060
6161 }
6262
6363 open ( ) {
6464 if ( ! this . closed )
65- ReactNativeBlobUtil . readStream ( this . path , this . encoding , this . bufferSize || 10240 , this . tick || - 1 , this . streamId )
65+ ReactNativeBlobUtil . readStream ( this . path , this . encoding , this . bufferSize || 10240 , this . tick || - 1 , this . streamId ) ;
6666 else
67- throw new Error ( 'Stream closed' )
67+ throw new Error ( 'Stream closed' ) ;
6868 }
6969
7070 onData ( fn :( ) = > void ) {
71- this . _onData = fn
71+ this . _onData = fn ;
7272 }
7373
7474 onError ( fn ) {
75- this . _onError = fn
75+ this . _onError = fn ;
7676 }
7777
7878 onEnd ( fn ) {
79- this . _onEnd = fn
79+ this . _onEnd = fn ;
8080 }
8181
8282}
0 commit comments