Open this example in the interactive library
Source code
import { EventEmitter, once } from "node:events";
const emitter = new EventEmitter();
const ready = once(emitter, "ready");
emitter.emit("ready", 42);
console.log(await ready);
Sample output
[ 42 ]
