Skip to content

Commit

Permalink
Move shouldPropagate to a function
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmelnikow committed Apr 12, 2019
1 parent ae284f7 commit cf3ca67
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ function propagate(events, source, dest) {
return explicitPropagate(events, source, dest)
}

const shouldPropagate = eventName =>
events === undefined || events.includes(eventName)

const oldEmit = source.emit

// Returns true if the event had listeners, false otherwise.
Expand All @@ -23,7 +26,7 @@ function propagate(events, source, dest) {
const oldEmitHadListeners = oldEmit.call(source, eventName, ...args)

let destEmitHadListeners = false
if (events === undefined || events.includes(eventName)) {
if (shouldPropagate(eventName)) {
destEmitHadListeners = dest.emit(eventName, ...args)
}

Expand Down

0 comments on commit cf3ca67

Please sign in to comment.