Skip to content

Commit

Permalink
Fix linter issues by using forEach instead of for..of
Browse files Browse the repository at this point in the history
  • Loading branch information
hsource committed Jan 28, 2024
1 parent 8008356 commit 7a4426e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/EventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,21 @@ class EventEmitter {

emit(event, ...args) {
if (this.observers[event]) {
for (const [observer, numTimesAdded] of this.observers[event].entries()) {
const cloned = Array.from(this.observers[event].entries());
cloned.forEach(([observer, numTimesAdded]) => {
for (let i = 0; i < numTimesAdded; i++) {
observer(...args);
}
}
});
}

if (this.observers['*']) {
for (const [observer, numTimesAdded] of this.observers['*'].entries()) {
const cloned = Array.from(this.observers['*'].entries());
cloned.forEach(([observer, numTimesAdded]) => {
for (let i = 0; i < numTimesAdded; i++) {
observer.apply(observer, [event, ...args]);
}
}
});
}
}
}
Expand Down

0 comments on commit 7a4426e

Please sign in to comment.