nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
107.8k stars 29.7k forks source link

Missing documentation for process.emit #55731

Open bozzelliandrea opened 1 week ago

bozzelliandrea commented 1 week ago

Affected URL(s)

https://nodejs.org/api/process.html

Description of the problem

inside process page there is the docs for process.emitWarning() but is missing for the function process.emit() with following signatures:

emit(event: "beforeExit", code: number): boolean;
emit(event: "disconnect"): boolean;
emit(event: "exit", code: number): boolean;
emit(event: "rejectionHandled", promise: Promise<unknown>): boolean;
emit(event: "uncaughtException", error: Error): boolean;
emit(event: "uncaughtExceptionMonitor", error: Error): boolean;
emit(event: "unhandledRejection", reason: unknown, promise: Promise<unknown>): boolean;
emit(event: "warning", warning: Error): boolean;
emit(event: "message", message: unknown, sendHandle: unknown): this;
emit(event: Signals, signal?: Signals): boolean;
emit(
    event: "multipleResolves",
    type: MultipleResolveType,
    promise: Promise<unknown>,
    value: unknown,
): this;
emit(event: "worker", listener: WorkerListener): this;

is that correct?

RedYetiDev commented 1 week ago

I don't see an issue. The emitWarning function has nothing to do with emit function, despite the similar name.

Oh, you mean there is no documentation for the emit function. @nodejs/process is that intentional? iirc it is, as inherited functions aren't documented. (For example, the other event listener functions aren't there)

bozzelliandrea commented 1 week ago

@RedYetiDev Oh, you mean there is no documentation for the emit function yes exactly, since it's a public function from the process, I thought there was some documentation

joyeecheung commented 1 week ago

It probably just happened not to have any documentation because the documentation just says

https://github.com/nodejs/node/blob/2a965493a97917a3c3f39766effe66c3f388544c/doc/api/process.md#L22

and be done with it. But a documentation that references EventEmitter.emit would probably help too. PR welcomed ;)