From 74bb4b6bea48477e3b6a625cd7e7f67fb5695496 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`. Refs: https://github.com/nodejs/node/issues/26546 --- lib/net.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/net.js b/lib/net.js index ecf7258e8bb37f..b5025abb9e1ef3 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() { @@ -1411,7 +1413,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) {