mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-08 08:44:37 +08:00
events.once(emitter, name) was refused. The emitter dispatches statically emitted events to typed listeners through invokers built per argument tuple, so the lowering takes the event's tuple from the program-wide event table and builds a capture-free function that boxes that tuple into the any[] Node fulfills with, and one for the 'error' tuple. scr_events_once registers both as one-shot typed listeners behind emitted adapters (emitterOnceAdapter). The first to fire settles the promise (fulfilled with the arguments, or rejected with the error) and removes the other, as in Node; awaiting 'error' itself registers only the one listener. The shared state holds the emitter and the listener closures weakly, so a never-fired once creates no cycle. Options, computed or meta event names, EventTarget and stream receivers, and events emitted with computed names or checked-dynamic listeners stay refused. The fallback declarations type the result Promise<unknown[]>; under @types/node (Promise<any[]>) TypeScript code narrows it to unknown[].