diff --git a/lib/_http_server.js b/lib/_http_server.js index 8db7018cc98aba..40b32821fdf1c2 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -21,7 +21,6 @@ 'use strict'; -const util = require('util'); const net = require('net'); const assert = require('assert').ok; const { @@ -309,7 +308,8 @@ function Server(options, requestListener) { this.maxHeadersCount = null; this.headersTimeout = 40 * 1000; // 40 seconds } -util.inherits(Server, net.Server); +Object.setPrototypeOf(Server, net.Server); +Object.setPrototypeOf(Server.prototype, net.Server.prototype); Server.prototype.setTimeout = function setTimeout(msecs, callback) { diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index a72091b22e97fb..337ce56523fea9 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -347,7 +347,9 @@ function TLSSocket(socket, opts) { // Read on next tick so the caller has a chance to setup listeners process.nextTick(initRead, this, socket); } -util.inherits(TLSSocket, net.Socket); +Object.setPrototypeOf(TLSSocket, net.Socket); +Object.setPrototypeOf(TLSSocket.prototype, net.Socket.prototype); + exports.TLSSocket = TLSSocket; var proxiedMethods = [ @@ -881,7 +883,9 @@ function Server(options, listener) { } } -util.inherits(Server, net.Server); +Object.setPrototypeOf(Server, net.Server); +Object.setPrototypeOf(Server.prototype, net.Server.prototype); + exports.Server = Server; exports.createServer = function createServer(options, listener) { return new Server(options, listener); diff --git a/lib/https.js b/lib/https.js index 9ac4cfd0d3873a..55134a2cfce4a0 100644 --- a/lib/https.js +++ b/lib/https.js @@ -33,7 +33,6 @@ const { kServerResponse } = require('_http_server'); const { ClientRequest } = require('_http_client'); -const { inherits } = util; const debug = util.debuglog('https'); const { URL, urlToOptions, searchParamsSymbol } = require('internal/url'); const { IncomingMessage, ServerResponse } = require('http'); @@ -76,7 +75,8 @@ function Server(opts, requestListener) { this.maxHeadersCount = null; this.headersTimeout = 40 * 1000; // 40 seconds } -inherits(Server, tls.Server); +Object.setPrototypeOf(Server, tls.Server); +Object.setPrototypeOf(Server.prototype, tls.Server.prototype); Server.prototype.setTimeout = HttpServer.prototype.setTimeout; diff --git a/lib/internal/streams/lazy_transform.js b/lib/internal/streams/lazy_transform.js index c4d8c64b3dd041..a965284202aeb4 100644 --- a/lib/internal/streams/lazy_transform.js +++ b/lib/internal/streams/lazy_transform.js @@ -4,7 +4,6 @@ 'use strict'; const stream = require('stream'); -const util = require('util'); const { getDefaultEncoding @@ -17,7 +16,8 @@ function LazyTransform(options) { this.writable = true; this.readable = true; } -util.inherits(LazyTransform, stream.Transform); +Object.setPrototypeOf(LazyTransform, stream.Transform); +Object.setPrototypeOf(LazyTransform.prototype, stream.Transform.prototype); function makeGetter(name) { return function() { diff --git a/lib/net.js b/lib/net.js index 7680c8860e1521..cbeaa174201f83 100644 --- a/lib/net.js +++ b/lib/net.js @@ -331,7 +331,8 @@ function Socket(options) { this[kBytesRead] = 0; this[kBytesWritten] = 0; } -util.inherits(Socket, stream.Duplex); +Object.setPrototypeOf(Socket, stream.Duplex); +Object.setPrototypeOf(Socket.prototype, stream.Duplex.prototype); // Refresh existing timeouts. Socket.prototype._unrefTimer = function _unrefTimer() { diff --git a/lib/tty.js b/lib/tty.js index 6efaac6e43215f..3b8d004b65aff7 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -21,7 +21,6 @@ 'use strict'; -const { inherits } = require('util'); const net = require('net'); const { TTY, isTTY } = internalBinding('tty_wrap'); const errors = require('internal/errors'); @@ -58,7 +57,8 @@ function ReadStream(fd, options) { this.isRaw = false; this.isTTY = true; } -inherits(ReadStream, net.Socket); +Object.setPrototypeOf(ReadStream, net.Socket); +Object.setPrototypeOf(ReadStream.prototype, net.Socket.prototype); ReadStream.prototype.setRawMode = function(flag) { flag = !!flag; @@ -103,7 +103,8 @@ function WriteStream(fd) { this.rows = winSize[1]; } } -inherits(WriteStream, net.Socket); +Object.setPrototypeOf(WriteStream, net.Socket); +Object.setPrototypeOf(WriteStream.prototype, net.Socket.prototype); WriteStream.prototype.isTTY = true; diff --git a/test/parallel/test-net-access-byteswritten.js b/test/parallel/test-net-access-byteswritten.js index c928ab27c6d146..da63d68f6cd613 100644 --- a/test/parallel/test-net-access-byteswritten.js +++ b/test/parallel/test-net-access-byteswritten.js @@ -12,8 +12,10 @@ const tty = require('tty'); // Check that the bytesWritten getter doesn't crash if object isn't // constructed. assert.strictEqual(net.Socket.prototype.bytesWritten, undefined); -assert.strictEqual(tls.TLSSocket.super_.prototype.bytesWritten, undefined); +assert.strictEqual(Object.getPrototypeOf(tls.TLSSocket).prototype.bytesWritten, + undefined); assert.strictEqual(tls.TLSSocket.prototype.bytesWritten, undefined); -assert.strictEqual(tty.ReadStream.super_.prototype.bytesWritten, undefined); +assert.strictEqual(Object.getPrototypeOf(tty.ReadStream).prototype.bytesWritten, + undefined); assert.strictEqual(tty.ReadStream.prototype.bytesWritten, undefined); assert.strictEqual(tty.WriteStream.prototype.bytesWritten, undefined);