File tree 1 file changed +15
-0
lines changed
03-callbacks-and-events/10-eventemitter-extend
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,18 @@ class FindRegex extends EventEmitter {
14
14
}
15
15
16
16
find ( ) {
17
+ console . log ( 'find' )
18
+
19
+ process . nextTick ( ( ) => console . log ( "nextTick emit" , this . emit ( 'nextTick_start' , this . files ) ) ) ;
20
+
21
+ Promise . resolve ( ) . then ( ( ) => {
22
+ console . log ( "promise emit" , this . emit ( 'promise_start' , this . files ) ) ;
23
+ } ) ;
24
+
25
+ new Promise ( ( resolve , reject ) => {
26
+ resolve ( ) ;
27
+ } ) . then ( ( ) => console . log ( "new promise emit" , this . emit ( 'new_promise_start' , this . files ) ) ) ;
28
+
17
29
for ( const file of this . files ) {
18
30
readFile ( file , 'utf8' , ( err , content ) => {
19
31
if ( err ) {
@@ -39,3 +51,6 @@ findRegexInstance
39
51
. find ( )
40
52
. on ( 'found' , ( file , match ) => console . log ( `Matched "${ match } " in file ${ file } ` ) )
41
53
. on ( 'error' , err => console . error ( `Error emitted ${ err . message } ` ) )
54
+ . on ( 'nextTick_start' , files => console . log ( `(nextTick) Started find in ${ files } ` ) )
55
+ . on ( 'new_promise_start' , files => console . log ( `(new_promise) Started find in ${ files } ` ) )
56
+ . on ( 'promise_start' , files => console . log ( `(promise) Started find in ${ files } ` ) ) ;
You can’t perform that action at this time.
0 commit comments