@@ -7,7 +7,7 @@ var utils = require("./utils");
77 * @return {Rx.Observable<{type: string, files: Array<any>}> }
88 */
99function fileChanges ( subject , options ) {
10- var operators = [
10+ const operators = [
1111 {
1212 option : "reloadThrottle" ,
1313 fnName : "throttle"
@@ -18,40 +18,30 @@ function fileChanges(subject, options) {
1818 }
1919 ] ;
2020
21- var scheduler = options . getIn ( [ "debug" , "scheduler" ] ) ;
21+ const scheduler = options . getIn ( [ "debug" , "scheduler" ] ) ;
2222
2323 /**
24- * if the 'reloadDebounce' option was provided, create
25- * a stream buffered/debounced stream of events
24+ * Create a stream buffered/debounced stream of events
2625 */
27- var initial = ( function ( ) {
28- if ( options . get ( "reloadDebounce" ) > 0 ) {
29- return getAggregatedDebouncedStream ( subject , options , scheduler ) ;
30- }
31- return subject ;
32- } ) ( ) ;
26+ const initial = getAggregatedDebouncedStream ( subject , options , scheduler ) ;
3327
34- return applyOperators ( operators , initial , options , scheduler ) . map ( function (
35- xs
36- ) {
37- var items = [ ] . concat ( xs ) ;
38- var paths = items . map ( function ( x ) {
39- return x . path ;
40- } ) ;
28+ return applyOperators ( operators , initial , options , scheduler )
29+ . map ( function ( items ) {
30+ const paths = items . map ( x => x . path ) ;
4131
42- if (
43- utils . willCauseReload ( paths , options . get ( "injectFileTypes" ) . toJS ( ) )
44- ) {
32+ if (
33+ utils . willCauseReload ( paths , options . get ( "injectFileTypes" ) . toJS ( ) )
34+ ) {
35+ return {
36+ type : "reload" ,
37+ files : items
38+ } ;
39+ }
4540 return {
46- type : "reload " ,
41+ type : "inject " ,
4742 files : items
4843 } ;
49- }
50- return {
51- type : "inject" ,
52- files : items
53- } ;
54- } ) ;
44+ } )
5545}
5646module . exports . fileChanges = fileChanges ;
5747
@@ -113,19 +103,4 @@ function getAggregatedDebouncedStream(subject, options, scheduler) {
113103 return options . get ( "watchEvents" ) . indexOf ( x . event ) > - 1 ;
114104 } )
115105 . buffer ( subject . debounce ( options . get ( "reloadDebounce" ) , scheduler ) )
116- . map ( function ( buffered ) {
117- return buffered . reduce ( function ( acc , item ) {
118- if ( ! acc [ item . path ] ) acc [ item . path ] = item ;
119- if ( acc [ item . path ] ) acc [ item . path ] = item ;
120- return acc ;
121- } , { } ) ;
122- } )
123- . map ( function ( group ) {
124- return Object . keys ( group ) . map ( function ( key ) {
125- return group [ key ] ;
126- } ) ;
127- } )
128- . filter ( function ( x ) {
129- return x . length ;
130- } ) ;
131106}
0 commit comments