Medium
You need to implement a type-safe event emitter that supports wildcard listeners. Which implementation correctly handles all the edge cases?
1class EventEmitter {2 constructor() {3 this.events = new Map();4 this.wildcards = new Set();5 }67 // Missing implementation8 ____________________9 ____________________10 ____________________11 ____________________12}1314// Usage:15const emitter = new EventEmitter();1617emitter.on('user:*', (event, data) => {18 console.log(`User event: ${event}`, data);19});2021emitter.on('user:login', (data) => {22 console.log('User logged in:', data);23});2425emitter.emit('user:login', { id: 1, name: 'John' });