Skip to main content

Module events

Module events 

Source
Expand description

Node events module: EventEmitter. The emitter is an object tagged @@native = "EventEmitter" with a hidden @@on map (event name → the ordered RAW listener array: a once registration is stored as node’s _onceWrap wrapper, whose .listener is the function registered). emit collects listeners, releases the host borrow, then invokes each so callbacks can re-enter the host.

Constants§

METHODS
The EventEmitter method names, exposed so EventEmitter.prototype can be enumerated / copied (express does mixin(app, EventEmitter.prototype) to make its app function an emitter).
STATIC_METHODS
Static functions on the events module namespace. EventEmitter (the self-ref ctor) and EventEmitterAsyncResource are handled by the parent.

Functions§

inherits_proto_method
Whether an emitter-backed native instance tagged tag inherits name from EventEmitter.prototype — so reading it gives that very function — rather than from a class that overrides it (a Readable’s on, measured: EMITTER_OVERRIDES).
instance_call
is_proto_method
Whether name is one of EventEmitter.prototype’s methods (measured: CLASS_PROTO_ARITY, which also makes an alias the method it is, so EventEmitter.prototype.on === EventEmitter.prototype.addListener).
new_emitter
Construct a fresh EventEmitter.
static_call
Dispatch a static events.<method>(...). Returns None for names this module does not own (e.g. EventEmitter) so the parent’s specific arm wins.