Loading homepage
Build an event emitter whose subscriptions return objects that can unsubscribe themselves.
Input: const emitter = new EventEmitter(); const subscription = emitter.subscribe("ready", (...args) => console.log(args)); emitter.emit("ready", 1, "ok"); subscription.unsubscribe(); emitter.emit("ready", 2); Output: First emit logs [1, "ok"] and returns true; second returns false.
Input: const a = emitter.subscribe("change", callback); const b = emitter.subscribe("change", callback); a.unsubscribe(); Output: The registration returned as b remains active.
Implement the exported class in index.js or index.ts. Tests provide fixtures for the required behavior.