diff --git a/lib/_http_agent.js b/lib/_http_agent.js index c90955bf0e49da..ac482bcfea37d8 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -106,6 +106,7 @@ function Agent(options) { }); } Object.setPrototypeOf(Agent.prototype, EventEmitter.prototype); +Object.setPrototypeOf(Agent, EventEmitter); Agent.defaultMaxSockets = Infinity; diff --git a/lib/_http_client.js b/lib/_http_client.js index fd69bb28aa5383..a5bd035bd968a3 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -280,6 +280,7 @@ function ClientRequest(input, options, cb) { this._deferToConnect(null, null, () => this._flush()); } Object.setPrototypeOf(ClientRequest.prototype, OutgoingMessage.prototype); +Object.setPrototypeOf(ClientRequest, OutgoingMessage); ClientRequest.prototype._finish = function _finish() { DTRACE_HTTP_CLIENT_REQUEST(this, this.connection); diff --git a/lib/_http_incoming.js b/lib/_http_incoming.js index cd3055ebef11b4..bf2fee693225c9 100644 --- a/lib/_http_incoming.js +++ b/lib/_http_incoming.js @@ -72,6 +72,7 @@ function IncomingMessage(socket) { this._dumped = false; } Object.setPrototypeOf(IncomingMessage.prototype, Stream.Readable.prototype); +Object.setPrototypeOf(IncomingMessage, Stream.Readable); IncomingMessage.prototype.setTimeout = function setTimeout(msecs, callback) { if (callback) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 5fc23dde570eb4..eb68d091c68407 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -107,6 +107,7 @@ function OutgoingMessage() { this._onPendingData = noopPendingOutput; } Object.setPrototypeOf(OutgoingMessage.prototype, Stream.prototype); +Object.setPrototypeOf(OutgoingMessage, Stream); Object.defineProperty(OutgoingMessage.prototype, '_headers', { diff --git a/lib/_http_server.js b/lib/_http_server.js index 0fee3d0c67eb99..2f5b939884a45c 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -138,6 +138,7 @@ function ServerResponse(req) { } } Object.setPrototypeOf(ServerResponse.prototype, OutgoingMessage.prototype); +Object.setPrototypeOf(ServerResponse, OutgoingMessage); ServerResponse.prototype._finish = function _finish() { DTRACE_HTTP_SERVER_RESPONSE(this.connection); diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js index d15e62527f9393..82cc23a38ca030 100644 --- a/lib/_stream_duplex.js +++ b/lib/_stream_duplex.js @@ -32,6 +32,7 @@ const Readable = require('_stream_readable'); const Writable = require('_stream_writable'); Object.setPrototypeOf(Duplex.prototype, Readable.prototype); +Object.setPrototypeOf(Duplex, Readable); { // Allow the keys array to be GC'ed. diff --git a/lib/_stream_passthrough.js b/lib/_stream_passthrough.js index c64e4368f1b7fb..404617f58eab1f 100644 --- a/lib/_stream_passthrough.js +++ b/lib/_stream_passthrough.js @@ -29,6 +29,7 @@ module.exports = PassThrough; const Transform = require('_stream_transform'); Object.setPrototypeOf(PassThrough.prototype, Transform.prototype); +Object.setPrototypeOf(PassThrough, Transform); function PassThrough(options) { if (!(this instanceof PassThrough)) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index e5120debc6528b..d1a17fd066076d 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -45,6 +45,7 @@ let StringDecoder; let createReadableStreamAsyncIterator; Object.setPrototypeOf(Readable.prototype, Stream.prototype); +Object.setPrototypeOf(Readable, Stream); const { errorOrDestroy } = destroyImpl; const kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js index 5ed79ffeaa67ad..0a37b6a4d4490c 100644 --- a/lib/_stream_transform.js +++ b/lib/_stream_transform.js @@ -72,6 +72,7 @@ const { } = require('internal/errors').codes; const Duplex = require('_stream_duplex'); Object.setPrototypeOf(Transform.prototype, Duplex.prototype); +Object.setPrototypeOf(Transform, Duplex); function afterTransform(er, data) { diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index a1b3f7095149bb..c2f5a5ec4ac9d1 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -47,6 +47,7 @@ const { const { errorOrDestroy } = destroyImpl; Object.setPrototypeOf(Writable.prototype, Stream.prototype); +Object.setPrototypeOf(Writable, Stream); function nop() {} diff --git a/lib/dgram.js b/lib/dgram.js index d1b4d763fccb2f..4751debff1500c 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -109,6 +109,7 @@ function Socket(type, listener) { }; } Object.setPrototypeOf(Socket.prototype, EventEmitter.prototype); +Object.setPrototypeOf(Socket, EventEmitter); function createSocket(type, listener) { diff --git a/lib/https.js b/lib/https.js index 335825a3813dd0..4a83853d078d9e 100644 --- a/lib/https.js +++ b/lib/https.js @@ -150,6 +150,7 @@ function Agent(options) { }; } Object.setPrototypeOf(Agent.prototype, HttpAgent.prototype); +Object.setPrototypeOf(Agent, HttpAgent); Agent.prototype.createConnection = createConnection; Agent.prototype.getName = function getName(options) { diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index c8274fe10eee6b..cd942e65b59798 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -266,6 +266,7 @@ function ChildProcess() { }; } Object.setPrototypeOf(ChildProcess.prototype, EventEmitter.prototype); +Object.setPrototypeOf(ChildProcess, EventEmitter); function flushStdio(subprocess) { diff --git a/lib/internal/cluster/worker.js b/lib/internal/cluster/worker.js index 772526e657cea0..8033f82f2e24d0 100644 --- a/lib/internal/cluster/worker.js +++ b/lib/internal/cluster/worker.js @@ -30,6 +30,7 @@ function Worker(options) { } Object.setPrototypeOf(Worker.prototype, EventEmitter.prototype); +Object.setPrototypeOf(Worker, EventEmitter); Worker.prototype.kill = function() { this.destroy.apply(this, arguments); diff --git a/lib/internal/crypto/cipher.js b/lib/internal/crypto/cipher.js index 7f88320d6ce441..1e5dc91c8d5790 100644 --- a/lib/internal/crypto/cipher.js +++ b/lib/internal/crypto/cipher.js @@ -124,6 +124,7 @@ function Cipher(cipher, password, options) { } Object.setPrototypeOf(Cipher.prototype, LazyTransform.prototype); +Object.setPrototypeOf(Cipher, LazyTransform); Cipher.prototype._transform = function _transform(chunk, encoding, callback) { this.push(this[kHandle].update(chunk, encoding)); @@ -254,6 +255,7 @@ function addCipherPrototypeFunctions(constructor) { } Object.setPrototypeOf(Cipheriv.prototype, LazyTransform.prototype); +Object.setPrototypeOf(Cipheriv, LazyTransform); addCipherPrototypeFunctions(Cipheriv); legacyNativeHandle(Cipheriv); @@ -265,6 +267,7 @@ function Decipher(cipher, password, options) { } Object.setPrototypeOf(Decipher.prototype, LazyTransform.prototype); +Object.setPrototypeOf(Decipher, LazyTransform); addCipherPrototypeFunctions(Decipher); legacyNativeHandle(Decipher); @@ -277,6 +280,7 @@ function Decipheriv(cipher, key, iv, options) { } Object.setPrototypeOf(Decipheriv.prototype, LazyTransform.prototype); +Object.setPrototypeOf(Decipheriv, LazyTransform); addCipherPrototypeFunctions(Decipheriv); legacyNativeHandle(Decipheriv); diff --git a/lib/internal/crypto/hash.js b/lib/internal/crypto/hash.js index 460e47138ea870..f289d11cf8b9c0 100644 --- a/lib/internal/crypto/hash.js +++ b/lib/internal/crypto/hash.js @@ -39,6 +39,7 @@ function Hash(algorithm, options) { } Object.setPrototypeOf(Hash.prototype, LazyTransform.prototype); +Object.setPrototypeOf(Hash, LazyTransform); Hash.prototype._transform = function _transform(chunk, encoding, callback) { this[kHandle].update(chunk, encoding); @@ -100,6 +101,7 @@ function Hmac(hmac, key, options) { } Object.setPrototypeOf(Hmac.prototype, LazyTransform.prototype); +Object.setPrototypeOf(Hmac, LazyTransform); Hmac.prototype.update = Hash.prototype.update; diff --git a/lib/internal/crypto/sig.js b/lib/internal/crypto/sig.js index 09981b13d569a7..fa2d4998b6c990 100644 --- a/lib/internal/crypto/sig.js +++ b/lib/internal/crypto/sig.js @@ -30,6 +30,7 @@ function Sign(algorithm, options) { } Object.setPrototypeOf(Sign.prototype, Writable.prototype); +Object.setPrototypeOf(Sign, Writable); Sign.prototype._write = function _write(chunk, encoding, callback) { this.update(chunk, encoding); @@ -101,6 +102,7 @@ function Verify(algorithm, options) { } Object.setPrototypeOf(Verify.prototype, Writable.prototype); +Object.setPrototypeOf(Verify, Writable); Verify.prototype._write = Sign.prototype._write; Verify.prototype.update = Sign.prototype.update; diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index a79dfca9d51837..059f203597500b 100644 --- a/lib/internal/fs/streams.js +++ b/lib/internal/fs/streams.js @@ -119,6 +119,7 @@ function ReadStream(path, options) { }); } Object.setPrototypeOf(ReadStream.prototype, Readable.prototype); +Object.setPrototypeOf(ReadStream, Readable); ReadStream.prototype.open = function() { fs.open(this.path, this.flags, this.mode, (er, fd) => { @@ -273,6 +274,7 @@ function WriteStream(path, options) { this.open(); } Object.setPrototypeOf(WriteStream.prototype, Writable.prototype); +Object.setPrototypeOf(WriteStream, Writable); WriteStream.prototype._final = function(callback) { if (this.autoClose) { diff --git a/lib/internal/fs/sync_write_stream.js b/lib/internal/fs/sync_write_stream.js index fda3b8947d6c06..1e7c6a50a96d6d 100644 --- a/lib/internal/fs/sync_write_stream.js +++ b/lib/internal/fs/sync_write_stream.js @@ -16,6 +16,7 @@ function SyncWriteStream(fd, options) { } Object.setPrototypeOf(SyncWriteStream.prototype, Writable.prototype); +Object.setPrototypeOf(SyncWriteStream, Writable); SyncWriteStream.prototype._write = function(chunk, encoding, cb) { writeSync(this.fd, chunk, 0, chunk.length); diff --git a/lib/internal/fs/watchers.js b/lib/internal/fs/watchers.js index 46a520a45c71db..83c9b429ef6063 100644 --- a/lib/internal/fs/watchers.js +++ b/lib/internal/fs/watchers.js @@ -36,6 +36,7 @@ function StatWatcher(bigint) { this[kUseBigint] = bigint; } Object.setPrototypeOf(StatWatcher.prototype, EventEmitter.prototype); +Object.setPrototypeOf(StatWatcher, EventEmitter); function onchange(newStatus, stats) { const self = this[owner_symbol]; @@ -132,6 +133,7 @@ function FSWatcher() { }; } Object.setPrototypeOf(FSWatcher.prototype, EventEmitter.prototype); +Object.setPrototypeOf(FSWatcher, EventEmitter); // FIXME(joyeecheung): this method is not documented. diff --git a/lib/internal/streams/legacy.js b/lib/internal/streams/legacy.js index 016a50d140793e..85c88c73f01f06 100644 --- a/lib/internal/streams/legacy.js +++ b/lib/internal/streams/legacy.js @@ -6,6 +6,7 @@ function Stream() { EE.call(this); } Object.setPrototypeOf(Stream.prototype, EE.prototype); +Object.setPrototypeOf(Stream, EE); Stream.prototype.pipe = function(dest, options) { var source = this; diff --git a/lib/net.js b/lib/net.js index 70670c2ffd5196..a46844adf3e9a0 100644 --- a/lib/net.js +++ b/lib/net.js @@ -1146,6 +1146,7 @@ function Server(options, connectionListener) { this.pauseOnConnect = !!options.pauseOnConnect; } Object.setPrototypeOf(Server.prototype, EventEmitter.prototype); +Object.setPrototypeOf(Server, EventEmitter); function toNumber(x) { return (x = Number(x)) >= 0 ? x : false; } diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index b84498055fdba4..9b40c8f97735c8 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -209,6 +209,7 @@ class PerformanceNodeTiming { } Object.setPrototypeOf( PerformanceNodeTiming.prototype, PerformanceEntry.prototype); +Object.setPrototypeOf(PerformanceNodeTiming, PerformanceEntry); const nodeTiming = new PerformanceNodeTiming(); diff --git a/lib/readline.js b/lib/readline.js index b2ab2791d6122e..e55507416b0b08 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -246,6 +246,7 @@ function Interface(input, output, completer, terminal) { } Object.setPrototypeOf(Interface.prototype, EventEmitter.prototype); +Object.setPrototypeOf(Interface, EventEmitter); Object.defineProperty(Interface.prototype, 'columns', { configurable: true, diff --git a/lib/repl.js b/lib/repl.js index 6922438fbe8e56..1ab4031f09cb9a 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -753,6 +753,8 @@ function REPLServer(prompt, self.displayPrompt(); } Object.setPrototypeOf(REPLServer.prototype, Interface.prototype); +Object.setPrototypeOf(REPLServer, Interface); + exports.REPLServer = REPLServer; exports.REPL_MODE_SLOPPY = Symbol('repl-sloppy'); @@ -923,6 +925,7 @@ function ArrayStream() { }; } Object.setPrototypeOf(ArrayStream.prototype, Stream.prototype); +Object.setPrototypeOf(ArrayStream, Stream); ArrayStream.prototype.readable = true; ArrayStream.prototype.writable = true; ArrayStream.prototype.resume = function() {}; @@ -1514,4 +1517,5 @@ function Recoverable(err) { this.err = err; } Object.setPrototypeOf(Recoverable.prototype, SyntaxError.prototype); +Object.setPrototypeOf(Recoverable, SyntaxError); exports.Recoverable = Recoverable; diff --git a/lib/zlib.js b/lib/zlib.js index ba7a3c5f05b103..fc1eeaf2b099fc 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -318,6 +318,7 @@ function Zlib(opts, mode) { this.once('end', this.close); } Object.setPrototypeOf(Zlib.prototype, Transform.prototype); +Object.setPrototypeOf(Zlib, Transform); Object.defineProperty(Zlib.prototype, '_closed', { configurable: true, @@ -648,6 +649,7 @@ function Deflate(opts) { Zlib.call(this, opts, DEFLATE); } Object.setPrototypeOf(Deflate.prototype, Zlib.prototype); +Object.setPrototypeOf(Deflate, Zlib); function Inflate(opts) { if (!(this instanceof Inflate)) @@ -655,6 +657,7 @@ function Inflate(opts) { Zlib.call(this, opts, INFLATE); } Object.setPrototypeOf(Inflate.prototype, Zlib.prototype); +Object.setPrototypeOf(Inflate, Zlib); function Gzip(opts) { if (!(this instanceof Gzip)) @@ -662,6 +665,7 @@ function Gzip(opts) { Zlib.call(this, opts, GZIP); } Object.setPrototypeOf(Gzip.prototype, Zlib.prototype); +Object.setPrototypeOf(Gzip, Zlib); function Gunzip(opts) { if (!(this instanceof Gunzip)) @@ -669,6 +673,7 @@ function Gunzip(opts) { Zlib.call(this, opts, GUNZIP); } Object.setPrototypeOf(Gunzip.prototype, Zlib.prototype); +Object.setPrototypeOf(Gunzip, Zlib); function DeflateRaw(opts) { if (opts && opts.windowBits === 8) opts.windowBits = 9; @@ -677,6 +682,7 @@ function DeflateRaw(opts) { Zlib.call(this, opts, DEFLATERAW); } Object.setPrototypeOf(DeflateRaw.prototype, Zlib.prototype); +Object.setPrototypeOf(DeflateRaw, Zlib); function InflateRaw(opts) { if (!(this instanceof InflateRaw)) @@ -684,6 +690,7 @@ function InflateRaw(opts) { Zlib.call(this, opts, INFLATERAW); } Object.setPrototypeOf(InflateRaw.prototype, Zlib.prototype); +Object.setPrototypeOf(InflateRaw, Zlib); function Unzip(opts) { if (!(this instanceof Unzip)) @@ -691,6 +698,7 @@ function Unzip(opts) { Zlib.call(this, opts, UNZIP); } Object.setPrototypeOf(Unzip.prototype, Zlib.prototype); +Object.setPrototypeOf(Unzip, Zlib); function createConvenienceMethod(ctor, sync) { if (sync) {