Skip to content

Commit b552139

Browse files
BeniChenitargos
authored andcommittedMar 27, 2019
stream: reduce internal usage of public require of util
PR-URL: #26698 Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent f597b37 commit b552139

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed
 

‎lib/internal/js_stream_socket.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
'use strict';
22

33
const assert = require('internal/assert');
4-
const util = require('util');
54
const { Socket } = require('net');
65
const { JSStream } = internalBinding('js_stream');
76
const uv = internalBinding('uv');
8-
const debug = util.debuglog('stream_socket');
7+
const debug = require('internal/util/debuglog').debuglog('stream_socket');
98
const { owner_symbol } = require('internal/async_hooks').symbols;
109
const { ERR_STREAM_WRAP } = require('internal/errors').codes;
1110

‎lib/internal/streams/buffer_list.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const { Buffer } = require('buffer');
4-
const { inspect } = require('util');
4+
const { inspect } = require('internal/util/inspect');
55

66
function copyBuffer(src, target, offset) {
77
Buffer.prototype.copy.call(src, target, offset);

‎lib/internal/streams/lazy_transform.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
'use strict';
55

66
const stream = require('stream');
7-
const util = require('util');
87

98
const {
109
getDefaultEncoding
@@ -17,7 +16,8 @@ function LazyTransform(options) {
1716
this.writable = true;
1817
this.readable = true;
1918
}
20-
util.inherits(LazyTransform, stream.Transform);
19+
Object.setPrototypeOf(LazyTransform.prototype, stream.Transform.prototype);
20+
Object.setPrototypeOf(LazyTransform, stream.Transform);
2121

2222
function makeGetter(name) {
2323
return function() {

‎lib/stream.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Stream.Stream = Stream;
4343

4444
// Internal utilities
4545
try {
46-
const types = require('util').types;
46+
const types = require('internal/util/types');
4747
if (types && typeof types.isUint8Array === 'function') {
4848
Stream._isUint8Array = types.isUint8Array;
4949
} else {

0 commit comments

Comments
 (0)