From e112fb4c221f9749fd9271c95a5f544476511292 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 a5f012ac3302bb..1c14df01ccb1e9 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, @@ -130,7 +131,7 @@ function getNewAsyncId(handle) { } -const debug = util.debuglog('net'); +const debug = debuglog('net'); function isPipeName(s) { return typeof s === 'string' && toNumber(s) === false; @@ -335,7 +336,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() { @@ -1412,7 +1414,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) {