Design Patterns
Event Emitter with .once() and Listener Count
mediumJS SpecificJS / TS3 tests
Problem Statement
Implement an enhanced Event Emitter class with `on(event, fn)`, `once(event, fn)`, `off(event, fn)`, `emit(event, ...args)`, and `listenerCount(event)`.
Examples
Example 1:
const emitter = new AdvancedEventEmitter();
emitter.once('greet', (name) => console.log('Hi ' + name));
emitter.emit('greet', 'Alice'); // logs 'Hi Alice'
emitter.emit('greet', 'Bob'); // does not logJavaScript & TypeScript starter code included
Run this as a live interviewPractice solo
3 test cases. No second person needed.