title: How can I handle multiple events with the same event handler function using Node.js EventEmitter?
body: <p>To simplify my problem a little bit let's break it down the following easy example.</p>
  <p>I have multiple <a href="https://nodejs.org/api/events.html" rel="nofollow noreferrer">event</a>-listeners listening for different things but in the end, I always want to call the same handler function.
  I know I can do something like this:</p>
  <pre><code>const { EventEmitter } = require(&quot;events&quot;);
  
  const emitter = new EventEmitter();
  
  const handler = () =&gt; console.log(&quot;the devil&quot;);
  
  emitter.on(&quot;runninwith&quot;, handler);
  emitter.on(&quot;sympathyfor&quot;, handler);
  emitter.on(&quot;shoutat&quot;, handler);
  
  emitter.emit(&quot;runninwith&quot;);
  emitter.emit(&quot;sympathyfor&quot;);
  </code></pre>
  <p>However, as you can see the code is repeating over and over again. I wonder if there is a handy workaround or another option that makes this easier. Maybe something similar to
  <code>emitter.on([&quot;runninwith&quot;, &quot;sympathyfor&quot;, &quot;shoutat&quot;], handler);</code> (Obviously doesn't work)?</p>
  <p>In short, is there a way to call the same event handler function when different events are fired?</p>