Skip to content
Permalink
Browse files

lib: move process prototype manipulation into setupProcessObject

Since no operation is requiring process to be an EventEmitter before
setupProcessObject is called, it's safe to set up the prototype chain
in setupProcessObject and make the main code path more readable.

PR-URL: #24089
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information...
joyeecheung authored and MylesBorins committed Nov 4, 2018
1 parent a67e04e commit a0b4f7a10e0c4818a593207493e4c6f0f67a9d52
Showing with 5 additions and 7 deletions.
  1. +5 −7 lib/internal/bootstrap/node.js
@@ -28,13 +28,6 @@
const isMainThread = internalBinding('worker').threadId === 0;

function startup() {
const EventEmitter = NativeModule.require('events');

const origProcProto = Object.getPrototypeOf(process);
Object.setPrototypeOf(origProcProto, EventEmitter.prototype);

EventEmitter.call(process);

setupProcessObject();

// Do this good and early, since it handles errors.
@@ -335,6 +328,11 @@
}

function setupProcessObject() {
const EventEmitter = NativeModule.require('events');
const origProcProto = Object.getPrototypeOf(process);
Object.setPrototypeOf(origProcProto, EventEmitter.prototype);
EventEmitter.call(process);

_setupProcessObject(pushValueToArray);

function pushValueToArray() {

0 comments on commit a0b4f7a

Please sign in to comment.
You can’t perform that action at this time.