Skip to content

Commit

Permalink
lib: consolidate redundant require() calls
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cjihrig authored and targos committed Jul 10, 2018
1 parent 11e9b4e commit 92d7921
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 1 addition & 3 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ const assert = require('assert').ok;
const Stream = require('stream');
const util = require('util');
const internalUtil = require('internal/util');
const internalHttp = require('internal/http');
const { outHeadersKey, utcDate } = require('internal/http');
const { Buffer } = require('buffer');
const common = require('_http_common');
const checkIsHttpToken = common._checkIsHttpToken;
const checkInvalidHeaderChar = common._checkInvalidHeaderChar;
const { outHeadersKey } = require('internal/http');
const {
defaultTriggerAsyncIdScope,
symbols: { async_id_symbol }
Expand All @@ -48,7 +47,6 @@ const {
} = require('internal/errors').codes;

const { CRLF, debug } = common;
const { utcDate } = internalHttp;

const kIsCorked = Symbol('isCorked');

Expand Down
3 changes: 1 addition & 2 deletions lib/internal/crypto/random.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { AsyncWrap, Providers } = process.binding('async_wrap');
const { Buffer } = require('buffer');
const { Buffer, kMaxLength } = require('buffer');
const { randomBytes: _randomBytes } = process.binding('crypto');
const {
ERR_INVALID_ARG_TYPE,
Expand All @@ -10,7 +10,6 @@ const {
} = require('internal/errors').codes;
const { isArrayBufferView } = require('internal/util/types');

const { kMaxLength } = require('buffer');
const kMaxUint32 = 2 ** 32 - 1;
const kMaxPossibleLength = Math.min(kMaxLength, kMaxUint32);

Expand Down
5 changes: 3 additions & 2 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

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

require('internal/util').assertCrypto();
const internalUtil = require('internal/util');
internalUtil.assertCrypto();

const { internalBinding } = require('internal/bootstrap/loaders');
const { async_id_symbol } = require('internal/async_hooks').symbols;
Expand Down Expand Up @@ -71,7 +72,7 @@ const { utcDate } = require('internal/http');
const {
promisify,
customInspectSymbol: kInspect
} = require('internal/util');
} = internalUtil;
const { isArrayBufferView } = require('internal/util/types');
const { defaultTriggerAsyncIdScope } = require('internal/async_hooks');
const { _connectionListener: httpConnectionListener } = http;
Expand Down
5 changes: 3 additions & 2 deletions lib/internal/modules/esm/translators.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ const fs = require('fs');
const { _makeLong } = require('path');
const { SafeMap } = require('internal/safe_globals');
const { URL } = require('url');
const debug = require('util').debuglog('esm');
const readFileAsync = require('util').promisify(fs.readFile);
const util = require('util');
const debug = util.debuglog('esm');
const readFileAsync = util.promisify(fs.readFile);
const readFileSync = fs.readFileSync;
const StringReplace = Function.call.bind(String.prototype.replace);
const JsonParse = JSON.parse;
Expand Down

0 comments on commit 92d7921

Please sign in to comment.