From b552139554ea7807514fcc3a3726c45bd8cfff21 Mon Sep 17 00:00:00 2001 From: Beni von Cheni Date: Sat, 16 Mar 2019 01:19:44 -0400 Subject: [PATCH] stream: reduce internal usage of public require of util MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/26698 Reviewed-By: Yongsheng Zhang Reviewed-By: Colin Ihrig Reviewed-By: Michaƫl Zasso Reviewed-By: Richard Lau Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- lib/internal/js_stream_socket.js | 3 +-- lib/internal/streams/buffer_list.js | 2 +- lib/internal/streams/lazy_transform.js | 4 ++-- lib/stream.js | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/internal/js_stream_socket.js b/lib/internal/js_stream_socket.js index 038aa56c4288c6..abfea278359640 100644 --- a/lib/internal/js_stream_socket.js +++ b/lib/internal/js_stream_socket.js @@ -1,11 +1,10 @@ 'use strict'; const assert = require('internal/assert'); -const util = require('util'); const { Socket } = require('net'); const { JSStream } = internalBinding('js_stream'); const uv = internalBinding('uv'); -const debug = util.debuglog('stream_socket'); +const debug = require('internal/util/debuglog').debuglog('stream_socket'); const { owner_symbol } = require('internal/async_hooks').symbols; const { ERR_STREAM_WRAP } = require('internal/errors').codes; diff --git a/lib/internal/streams/buffer_list.js b/lib/internal/streams/buffer_list.js index aa254309a03a5c..e0ba6e885cb60e 100644 --- a/lib/internal/streams/buffer_list.js +++ b/lib/internal/streams/buffer_list.js @@ -1,7 +1,7 @@ 'use strict'; const { Buffer } = require('buffer'); -const { inspect } = require('util'); +const { inspect } = require('internal/util/inspect'); function copyBuffer(src, target, offset) { Buffer.prototype.copy.call(src, target, offset); diff --git a/lib/internal/streams/lazy_transform.js b/lib/internal/streams/lazy_transform.js index c4d8c64b3dd041..7fc7f899c606cb 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.prototype, stream.Transform.prototype); +Object.setPrototypeOf(LazyTransform, stream.Transform); function makeGetter(name) { return function() { diff --git a/lib/stream.js b/lib/stream.js index dfe61aaf09d95d..97c86f7d6faad9 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -43,7 +43,7 @@ Stream.Stream = Stream; // Internal utilities try { - const types = require('util').types; + const types = require('internal/util/types'); if (types && typeof types.isUint8Array === 'function') { Stream._isUint8Array = types.isUint8Array; } else {