Browse Source

child_process: move anonymous class to top level

Move the anonymous class out of setupChannel to clarify code.

PR-URL: https://github.com/nodejs/node/pull/11147
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
v6
Jackson Tian 8 years ago
committed by Anna Henningsen
parent
commit
f9dc722eb5
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 35
      lib/internal/child_process.js

35
lib/internal/child_process.js

@ -407,22 +407,8 @@ ChildProcess.prototype.unref = function() {
if (this._handle) this._handle.unref();
};
function setupChannel(target, channel) {
target.channel = channel;
// _channel can be deprecated in version 8
Object.defineProperty(target, '_channel', {
get() { return target.channel; },
set(val) { target.channel = val; },
enumerable: true
});
target._handleQueue = null;
target._pendingHandle = null;
const control = new class extends EventEmitter {
constructor() {
class Control extends EventEmitter {
constructor(channel) {
super();
this.channel = channel;
this.refs = 0;
@ -438,7 +424,22 @@ function setupChannel(target, channel) {
this.emit('unref');
}
}
}();
}
function setupChannel(target, channel) {
target.channel = channel;
// _channel can be deprecated in version 8
Object.defineProperty(target, '_channel', {
get() { return target.channel; },
set(val) { target.channel = val; },
enumerable: true
});
target._handleQueue = null;
target._pendingHandle = null;
const control = new Control(channel);
var decoder = new StringDecoder('utf8');
var jsonBuffer = '';

Loading…
Cancel
Save