Skip to content

Commit 92d7921

Browse files
cjihrigtargos
authored andcommitted
lib: consolidate redundant require() calls
PR-URL: #21699 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Jon Moss <me@jonathanmoss.me>
1 parent 11e9b4e commit 92d7921

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

‎lib/_http_outgoing.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ const assert = require('assert').ok;
2525
constStream=require('stream');
2626
constutil=require('util');
2727
constinternalUtil=require('internal/util');
28-
constinternalHttp=require('internal/http');
28+
const{ outHeadersKey, utcDate }=require('internal/http');
2929
const{ Buffer }=require('buffer');
3030
constcommon=require('_http_common');
3131
constcheckIsHttpToken=common._checkIsHttpToken;
3232
constcheckInvalidHeaderChar=common._checkInvalidHeaderChar;
33-
const{ outHeadersKey }=require('internal/http');
3433
const{
3534
defaultTriggerAsyncIdScope,
3635
symbols: { async_id_symbol }
@@ -48,7 +47,6 @@ const {
4847
}=require('internal/errors').codes;
4948

5049
const{CRLF, debug }=common;
51-
const{ utcDate }=internalHttp;
5250

5351
constkIsCorked=Symbol('isCorked');
5452

‎lib/internal/crypto/random.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const{ AsyncWrap, Providers }=process.binding('async_wrap');
4-
const{ Buffer }=require('buffer');
4+
const{ Buffer, kMaxLength}=require('buffer');
55
const{randomBytes: _randomBytes}=process.binding('crypto');
66
const{
77
ERR_INVALID_ARG_TYPE,
@@ -10,7 +10,6 @@ const {
1010
}=require('internal/errors').codes;
1111
const{ isArrayBufferView }=require('internal/util/types');
1212

13-
const{ kMaxLength }=require('buffer');
1413
constkMaxUint32=2**32-1;
1514
constkMaxPossibleLength=Math.min(kMaxLength,kMaxUint32);
1615

‎lib/internal/http2/core.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
/* eslint-disable no-use-before-define */
44

5-
require('internal/util').assertCrypto();
5+
constinternalUtil=require('internal/util');
6+
internalUtil.assertCrypto();
67

78
const{ internalBinding }=require('internal/bootstrap/loaders');
89
const{ async_id_symbol }=require('internal/async_hooks').symbols;
@@ -71,7 +72,7 @@ const { utcDate } = require('internal/http');
7172
const{
7273
promisify,
7374
customInspectSymbol: kInspect
74-
}=require('internal/util');
75+
}=internalUtil;
7576
const{ isArrayBufferView }=require('internal/util/types');
7677
const{ defaultTriggerAsyncIdScope }=require('internal/async_hooks');
7778
const{_connectionListener: httpConnectionListener}=http;

‎lib/internal/modules/esm/translators.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ const fs = require('fs');
1414
const{ _makeLong }=require('path');
1515
const{ SafeMap }=require('internal/safe_globals');
1616
const{URL}=require('url');
17-
constdebug=require('util').debuglog('esm');
18-
constreadFileAsync=require('util').promisify(fs.readFile);
17+
constutil=require('util');
18+
constdebug=util.debuglog('esm');
19+
constreadFileAsync=util.promisify(fs.readFile);
1920
constreadFileSync=fs.readFileSync;
2021
constStringReplace=Function.call.bind(String.prototype.replace);
2122
constJsonParse=JSON.parse;

0 commit comments

Comments
 (0)