From 5e06c3bc0b8000b1063aabf33cbce3a082a731a5 Mon Sep 17 00:00:00 2001 From: dnlup Date: Thu, 21 Mar 2019 16:30:52 +0100 Subject: [PATCH] net: remove usage of require('util') Use `require('internal/util/inspect').inspect` and `require('internal/util/debuglog').debuglog` instead of `require('util').debuglog` and `require('util').inspect`. PR-URL: https://github.com/nodejs/node/pull/26807 Refs: https://github.com/nodejs/node/issues/26546 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- lib/net.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/net.js b/lib/net.js index d363878a929404..db553ed6e4d769 100644 --- a/lib/net.js +++ b/lib/net.js @@ -23,7 +23,8 @@ const EventEmitter = require('events'); const stream = require('stream'); -const util = require('util'); +const { inspect } = require('internal/util/inspect'); +const { debuglog } = require('internal/util/debuglog'); const internalUtil = require('internal/util'); const { isIP, @@ -129,7 +130,7 @@ function getNewAsyncId(handle) { } -const debug = util.debuglog('net'); +const debug = debuglog('net'); function isPipeName(s) { return typeof s === 'string' && toNumber(s) === false; @@ -334,7 +335,8 @@ function Socket(options) { this[kBytesRead] = 0; this[kBytesWritten] = 0; } -util.inherits(Socket, stream.Duplex); +Object.setPrototypeOf(Socket.prototype, stream.Duplex.prototype); +Object.setPrototypeOf(Socket, stream.Duplex); // Refresh existing timeouts. Socket.prototype._unrefTimer = function _unrefTimer() { @@ -1432,7 +1434,7 @@ Server.prototype.listen = function(...args) { 'must have the property "port" or "path"'); } - throw new ERR_INVALID_OPT_VALUE('options', util.inspect(options)); + throw new ERR_INVALID_OPT_VALUE('options', inspect(options)); }; function lookupAndListen(self, port, address, backlog, exclusive, flags) {