Skip to content

Commit f71fe5f

Browse files
committed
3.1
1 parent 8f75db8 commit f71fe5f

File tree

1 file changed

+15
-0
lines changed
  • 03-callbacks-and-events/10-eventemitter-extend

1 file changed

+15
-0
lines changed

03-callbacks-and-events/10-eventemitter-extend/index.js

+15
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ class FindRegex extends EventEmitter {
1414
}
1515

1616
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+
1729
for (const file of this.files) {
1830
readFile(file, 'utf8', (err, content) => {
1931
if (err) {
@@ -39,3 +51,6 @@ findRegexInstance
3951
.find()
4052
.on('found', (file, match) => console.log(`Matched "${match}" in file ${file}`))
4153
.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}`));

0 commit comments

Comments
 (0)