function groupEvents(events) {
  /** @type { { [key: string]: EventDirective[] } } */
  const grouped = {}
  for (const event of events) {
    if (!grouped[event.name]) {
      grouped[event.name] = []
    }
    grouped[event.name].push(event)
  }
  return grouped
}
Groups all events in object,
with keys represinting each event name

@param {EventDirective[]} events
@returns { { [key: string]: EventDirective[] } } { click: [], keypress: [] }