From cf3ca67ba9955acc9bdff1a34b881b0e81cc5751 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Fri, 12 Apr 2019 12:59:36 -0400 Subject: [PATCH] Move shouldPropagate to a function --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 9ada897..ea46434 100644 --- a/index.js +++ b/index.js @@ -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. @@ -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) }