Lesson 10 — Emitter with once
A listener that runs only once
Node's EventEmitter lets code listen for named events (on) and emit them. once is a listener that removes itself after the first call — perfect for "when the server is ready, do this one time".
The trick: wrap the function, and inside the wrapper first remove the wrapper, then call the real function.
Note: this playground runs JavaScript in your browser, not in real Node, so Node-only tools (like fs or http) are not available. The exercise is a small plain-JS simulation of the Node idea.
Why it matters: one-time setup code (connect, warm up a cache) must not run again on every event.
Finish once(): inside wrapper, remove wrapper from the list before calling fn, so "ready" logs only once.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.