diff --git a/lib/_http_agent.js b/lib/_http_agent.js index e71f0cb441f86e..e3f9a58437330f 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -25,8 +25,8 @@ const net = require('net'); const util = require('util'); const EventEmitter = require('events'); const debug = util.debuglog('http'); -const async_id_symbol = process.binding('async_wrap').async_id_symbol; -const nextTick = require('internal/process/next_tick').nextTick; +const { async_id_symbol } = process.binding('async_wrap'); +const { nextTick } = require('internal/process/next_tick'); // New Agent code. diff --git a/lib/_http_client.js b/lib/_http_client.js index 98782e56e8ec25..f4ff4052f6631d 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -24,19 +24,21 @@ const util = require('util'); const net = require('net'); const url = require('url'); -const HTTPParser = process.binding('http_parser').HTTPParser; +const { HTTPParser } = process.binding('http_parser'); const assert = require('assert').ok; -const common = require('_http_common'); -const httpSocketSetup = common.httpSocketSetup; -const parsers = common.parsers; -const freeParser = common.freeParser; -const debug = common.debug; -const OutgoingMessage = require('_http_outgoing').OutgoingMessage; +const { + _checkIsHttpToken: checkIsHttpToken, + debug, + freeParser, + httpSocketSetup, + parsers +} = require('_http_common'); +const { OutgoingMessage } = require('_http_outgoing'); const Agent = require('_http_agent'); -const Buffer = require('buffer').Buffer; +const { Buffer } = require('buffer'); const { urlToOptions, searchParamsSymbol } = require('internal/url'); -const outHeadersKey = require('internal/http').outHeadersKey; -const nextTick = require('internal/process/next_tick').nextTick; +const { outHeadersKey } = require('internal/http'); +const { nextTick } = require('internal/process/next_tick'); // The actual list of disallowed characters in regexp form is more like: // /[^A-Za-z0-9\-._~!$&'()*+,;=/:@]/ @@ -149,7 +151,7 @@ function ClientRequest(options, cb) { } if (methodIsString && method) { - if (!common._checkIsHttpToken(method)) { + if (!checkIsHttpToken(method)) { throw new TypeError('Method must be a valid HTTP token'); } method = this.method = method.toUpperCase(); diff --git a/lib/_http_common.js b/lib/_http_common.js index 59eaec5811618e..a1fe29217f59d5 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -22,16 +22,17 @@ 'use strict'; const binding = process.binding('http_parser'); -const methods = binding.methods; -const HTTPParser = binding.HTTPParser; +const { methods, HTTPParser } = binding; const FreeList = require('internal/freelist'); -const ondrain = require('internal/http').ondrain; +const { ondrain } = require('internal/http'); const incoming = require('_http_incoming'); -const emitDestroy = require('async_hooks').emitDestroy; -const IncomingMessage = incoming.IncomingMessage; -const readStart = incoming.readStart; -const readStop = incoming.readStop; +const { emitDestroy } = require('async_hooks'); +const { + IncomingMessage, + readStart, + readStop +} = incoming; const debug = require('util').debuglog('http'); diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index ebc94ba95335b5..09141d679b01af 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -26,17 +26,16 @@ const Stream = require('stream'); const util = require('util'); const internalUtil = require('internal/util'); const internalHttp = require('internal/http'); -const Buffer = require('buffer').Buffer; +const { Buffer } = require('buffer'); const common = require('_http_common'); const checkIsHttpToken = common._checkIsHttpToken; const checkInvalidHeaderChar = common._checkInvalidHeaderChar; -const outHeadersKey = require('internal/http').outHeadersKey; -const async_id_symbol = process.binding('async_wrap').async_id_symbol; -const nextTick = require('internal/process/next_tick').nextTick; +const { outHeadersKey } = require('internal/http'); +const { async_id_symbol } = process.binding('async_wrap'); +const { nextTick } = require('internal/process/next_tick'); -const CRLF = common.CRLF; -const debug = common.debug; -const utcDate = internalHttp.utcDate; +const { CRLF, debug } = common; +const { utcDate } = internalHttp; var RE_FIELDS = /^(?:Connection|Transfer-Encoding|Content-Length|Date|Expect|Trailer|Upgrade)$/i; diff --git a/lib/_http_server.js b/lib/_http_server.js index df42a7e9167f61..c4a6918e147d95 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -23,17 +23,19 @@ const util = require('util'); const net = require('net'); -const HTTPParser = process.binding('http_parser').HTTPParser; +const { HTTPParser } = process.binding('http_parser'); const assert = require('assert').ok; -const common = require('_http_common'); -const parsers = common.parsers; -const freeParser = common.freeParser; -const debug = common.debug; -const CRLF = common.CRLF; -const continueExpression = common.continueExpression; -const chunkExpression = common.chunkExpression; -const httpSocketSetup = common.httpSocketSetup; -const OutgoingMessage = require('_http_outgoing').OutgoingMessage; +const { + parsers, + freeParser, + debug, + CRLF, + continueExpression, + chunkExpression, + httpSocketSetup, + _checkInvalidHeaderChar: checkInvalidHeaderChar +} = require('_http_common'); +const { OutgoingMessage } = require('_http_outgoing'); const { outHeadersKey, ondrain } = require('internal/http'); const STATUS_CODES = { @@ -222,7 +224,7 @@ function writeHead(statusCode, reason, obj) { headers = obj; } - if (common._checkInvalidHeaderChar(this.statusMessage)) + if (checkInvalidHeaderChar(this.statusMessage)) throw new Error('Invalid character in statusMessage.'); var statusLine = 'HTTP/1.1 ' + statusCode + ' ' + this.statusMessage + CRLF; diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 2a69942f394e33..4fc22ee5b8e01a 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -26,7 +26,7 @@ Readable.ReadableState = ReadableState; const EE = require('events'); const Stream = require('stream'); -const Buffer = require('buffer').Buffer; +const { Buffer } = require('buffer'); const util = require('util'); const debug = util.debuglog('stream'); const BufferList = require('internal/streams/BufferList'); diff --git a/lib/_stream_wrap.js b/lib/_stream_wrap.js index 25a77b8c4a9e8c..6da778ccb6bca1 100644 --- a/lib/_stream_wrap.js +++ b/lib/_stream_wrap.js @@ -2,11 +2,11 @@ const assert = require('assert'); const util = require('util'); -const Socket = require('net').Socket; -const JSStream = process.binding('js_stream').JSStream; // TODO(bmeurer): Change this back to const once hole checks are // properly optimized away early in Ignition+TurboFan. var Buffer = require('buffer').Buffer; +const { Socket } = require('net'); +const { JSStream } = process.binding('js_stream'); const uv = process.binding('uv'); const debug = util.debuglog('stream_wrap'); diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index d87072a967bf2c..626d3bcf515021 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -31,7 +31,7 @@ Writable.WritableState = WritableState; const util = require('util'); const internalUtil = require('internal/util'); const Stream = require('stream'); -const Buffer = require('buffer').Buffer; +const { Buffer } = require('buffer'); const destroyImpl = require('internal/streams/destroy'); util.inherits(Writable, Stream); diff --git a/lib/_tls_common.js b/lib/_tls_common.js index 3d191b8244871e..9b4f62745e5d80 100644 --- a/lib/_tls_common.js +++ b/lib/_tls_common.js @@ -23,8 +23,7 @@ const tls = require('tls'); -const SSL_OP_CIPHER_SERVER_PREFERENCE = - process.binding('constants').crypto.SSL_OP_CIPHER_SERVER_PREFERENCE; +const { SSL_OP_CIPHER_SERVER_PREFERENCE } = process.binding('constants').crypto; // Lazily loaded var crypto = null; diff --git a/lib/_tls_legacy.js b/lib/_tls_legacy.js index 745a55889993fb..07b95546b3307a 100644 --- a/lib/_tls_legacy.js +++ b/lib/_tls_legacy.js @@ -25,12 +25,12 @@ const internalUtil = require('internal/util'); internalUtil.assertCrypto(); const assert = require('assert'); -const Buffer = require('buffer').Buffer; +const { Buffer } = require('buffer'); const common = require('_tls_common'); -const Connection = process.binding('crypto').Connection; +const { Connection } = process.binding('crypto'); const EventEmitter = require('events'); const stream = require('stream'); -const Timer = process.binding('timer_wrap').Timer; +const { Timer } = process.binding('timer_wrap'); const tls = require('tls'); const util = require('util'); diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 04aa3cec37dda1..ea9d857939d918 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -29,13 +29,13 @@ const net = require('net'); const tls = require('tls'); const util = require('util'); const common = require('_tls_common'); -const StreamWrap = require('_stream_wrap').StreamWrap; -const Buffer = require('buffer').Buffer; +const { StreamWrap } = require('_stream_wrap'); +const { Buffer } = require('buffer'); const debug = util.debuglog('tls'); -const Timer = process.binding('timer_wrap').Timer; +const { Timer } = process.binding('timer_wrap'); const tls_wrap = process.binding('tls_wrap'); -const TCP = process.binding('tcp_wrap').TCP; -const Pipe = process.binding('pipe_wrap').Pipe; +const { TCP } = process.binding('tcp_wrap'); +const { Pipe } = process.binding('pipe_wrap'); const kDisableRenegotiation = Symbol('disable-renegotiation'); function onhandshakestart() { diff --git a/lib/child_process.js b/lib/child_process.js index 6e158211067299..545ee3887db6df 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -30,14 +30,17 @@ const debug = util.debuglog('child_process'); const uv = process.binding('uv'); const spawn_sync = process.binding('spawn_sync'); -const Buffer = require('buffer').Buffer; -const Pipe = process.binding('pipe_wrap').Pipe; +const { Buffer } = require('buffer'); +const { Pipe } = process.binding('pipe_wrap'); const child_process = require('internal/child_process'); +const { + _validateStdio, + setupChannel, + ChildProcess +} = child_process; const errnoException = util._errnoException; -const _validateStdio = child_process._validateStdio; -const setupChannel = child_process.setupChannel; -const ChildProcess = exports.ChildProcess = child_process.ChildProcess; +exports.ChildProcess = ChildProcess; function stdioStringToArray(option) { switch (option) { diff --git a/lib/dgram.js b/lib/dgram.js index 4b8eeea106dd47..ef07a4f85bdeed 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -23,18 +23,17 @@ const assert = require('assert'); const errors = require('internal/errors'); -const Buffer = require('buffer').Buffer; +const { Buffer } = require('buffer'); const dns = require('dns'); const util = require('util'); const { isUint8Array } = require('internal/util/types'); const EventEmitter = require('events'); -const setInitTriggerId = require('async_hooks').setInitTriggerId; -const UV_UDP_REUSEADDR = process.binding('constants').os.UV_UDP_REUSEADDR; -const async_id_symbol = process.binding('async_wrap').async_id_symbol; -const nextTick = require('internal/process/next_tick').nextTick; +const { setInitTriggerId } = require('async_hooks'); +const { UV_UDP_REUSEADDR } = process.binding('constants').os; +const { async_id_symbol } = process.binding('async_wrap'); +const { nextTick } = require('internal/process/next_tick'); -const UDP = process.binding('udp_wrap').UDP; -const SendWrap = process.binding('udp_wrap').SendWrap; +const { UDP, SendWrap } = process.binding('udp_wrap'); const BIND_STATE_UNBOUND = 0; const BIND_STATE_BINDING = 1; diff --git a/lib/dns.js b/lib/dns.js index 6d60c783b3f0fc..aad0ebb17cee12 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -25,7 +25,7 @@ const util = require('util'); const cares = process.binding('cares_wrap'); const uv = process.binding('uv'); -const internalNet = require('internal/net'); +const { isLegalPort } = require('internal/net'); const { customPromisifyArgs } = require('internal/util'); const { @@ -36,9 +36,6 @@ const { isIP } = cares; -const isLegalPort = internalNet.isLegalPort; - - function errnoException(err, syscall, hostname) { // FIXME(bnoordhuis) Remove this backwards compatibility nonsense and pass // the true error to the user. ENOTFOUND is not even a proper POSIX error! diff --git a/lib/domain.js b/lib/domain.js index 5cef123da82b54..10d304e86e20bf 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -28,7 +28,7 @@ const util = require('util'); const EventEmitter = require('events'); -const inherits = util.inherits; +const { inherits } = util; // communicate with events module, but don't require that // module to have to load this one, since this module has diff --git a/lib/fs.js b/lib/fs.js index 8959aa4800195d..9c72994a72e549 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -33,18 +33,19 @@ const { createPromise, promiseResolve } = process.binding('util'); const binding = process.binding('fs'); const fs = exports; -const Buffer = require('buffer').Buffer; +const { Buffer } = require('buffer'); const errors = require('internal/errors'); -const Stream = require('stream').Stream; +const { Readable, Writable } = require('stream'); const EventEmitter = require('events'); -const FSReqWrap = binding.FSReqWrap; -const FSEvent = process.binding('fs_event_wrap').FSEvent; +const { FSReqWrap } = binding; +const { FSEvent } = process.binding('fs_event_wrap'); const internalFS = require('internal/fs'); -const internalURL = require('internal/url'); +const { getPathFromURL } = require('internal/url'); const internalUtil = require('internal/util'); -const assertEncoding = internalFS.assertEncoding; -const stringToFlags = internalFS.stringToFlags; -const getPathFromURL = internalURL.getPathFromURL; +const { + assertEncoding, + stringToFlags +} = internalFS; Object.defineProperty(exports, 'constants', { configurable: false, @@ -52,11 +53,8 @@ Object.defineProperty(exports, 'constants', { value: constants }); -const Readable = Stream.Readable; -const Writable = Stream.Writable; - const kMinPoolSpace = 128; -const kMaxLength = require('buffer').kMaxLength; +const { kMaxLength } = require('buffer'); const isWindows = process.platform === 'win32'; diff --git a/lib/http.js b/lib/http.js index af3e8a017ce1b9..701a5ccb86cc21 100644 --- a/lib/http.js +++ b/lib/http.js @@ -22,14 +22,13 @@ 'use strict'; const agent = require('_http_agent'); -const client = require('_http_client'); +const { ClientRequest } = require('_http_client'); const common = require('_http_common'); const incoming = require('_http_incoming'); const outgoing = require('_http_outgoing'); const server = require('_http_server'); -const Server = server.Server; -const ClientRequest = client.ClientRequest; +const { Server } = server; function createServer(requestListener) { return new Server(requestListener); diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 3ad51fbe1a852f..49975f3347a1c4 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -1,27 +1,25 @@ 'use strict'; const errors = require('internal/errors'); -const StringDecoder = require('string_decoder').StringDecoder; +const { StringDecoder } = require('string_decoder'); const EventEmitter = require('events'); const net = require('net'); const dgram = require('dgram'); const util = require('util'); const assert = require('assert'); - -const Process = process.binding('process_wrap').Process; -const WriteWrap = process.binding('stream_wrap').WriteWrap; const uv = process.binding('uv'); -const Pipe = process.binding('pipe_wrap').Pipe; -const TTY = process.binding('tty_wrap').TTY; -const TCP = process.binding('tcp_wrap').TCP; -const UDP = process.binding('udp_wrap').UDP; +const { Process } = process.binding('process_wrap'); +const { WriteWrap } = process.binding('stream_wrap'); +const { Pipe } = process.binding('pipe_wrap'); +const { TTY } = process.binding('tty_wrap'); +const { TCP } = process.binding('tcp_wrap'); +const { UDP } = process.binding('udp_wrap'); const SocketList = require('internal/socket_list'); const { convertToValidSignal } = require('internal/util'); const { isUint8Array } = require('internal/util/types'); const errnoException = util._errnoException; -const SocketListSend = SocketList.SocketListSend; -const SocketListReceive = SocketList.SocketListReceive; +const { SocketListSend, SocketListReceive } = SocketList; const MAX_HANDLE_RETRANSMISSIONS = 3; diff --git a/lib/internal/cluster/master.js b/lib/internal/cluster/master.js index 4ccf0393223a23..f3d2e30a5b73f0 100644 --- a/lib/internal/cluster/master.js +++ b/lib/internal/cluster/master.js @@ -1,6 +1,6 @@ 'use strict'; const assert = require('assert'); -const fork = require('child_process').fork; +const { fork } = require('child_process'); const util = require('util'); const EventEmitter = require('events'); const RoundRobinHandle = require('internal/cluster/round_robin_handle'); diff --git a/lib/internal/fs.js b/lib/internal/fs.js index e7a7299b344355..05caf9c6496850 100644 --- a/lib/internal/fs.js +++ b/lib/internal/fs.js @@ -1,7 +1,7 @@ 'use strict'; -const Buffer = require('buffer').Buffer; -const Writable = require('stream').Writable; +const { Buffer } = require('buffer'); +const { Writable } = require('stream'); const fs = require('fs'); const util = require('util'); diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 7f5e615a7a88d5..a6dbd626ec882f 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -6,7 +6,7 @@ require('internal/util').assertCrypto(); const binding = process.binding('http2'); const assert = require('assert'); -const Buffer = require('buffer').Buffer; +const { Buffer } = require('buffer'); const EventEmitter = require('events'); const net = require('net'); const tls = require('tls'); diff --git a/lib/internal/process/write-coverage.js b/lib/internal/process/write-coverage.js index 50c55200d2185f..1657f5b47081f6 100644 --- a/lib/internal/process/write-coverage.js +++ b/lib/internal/process/write-coverage.js @@ -1,9 +1,7 @@ 'use strict'; const process = require('process'); const path = require('path'); -const fs = require('fs'); -const mkdirSync = fs.mkdirSync; -const writeFileSync = fs.writeFileSync; +const { mkdirSync, writeFileSync } = require('fs'); function writeCoverage() { if (!global.__coverage__) { diff --git a/lib/internal/repl.js b/lib/internal/repl.js index 874bfd6fbbd183..be4943cb47a139 100644 --- a/lib/internal/repl.js +++ b/lib/internal/repl.js @@ -1,6 +1,6 @@ 'use strict'; -const Interface = require('readline').Interface; +const { Interface } = require('readline'); const REPL = require('repl'); const path = require('path'); const fs = require('fs'); diff --git a/lib/internal/streams/BufferList.js b/lib/internal/streams/BufferList.js index 6e724e9fb85695..23d5a8a2db0eb7 100644 --- a/lib/internal/streams/BufferList.js +++ b/lib/internal/streams/BufferList.js @@ -1,6 +1,6 @@ 'use strict'; -const Buffer = require('buffer').Buffer; +const { Buffer } = require('buffer'); function copyBuffer(src, target, offset) { Buffer.prototype.copy.call(src, target, offset); diff --git a/lib/internal/util.js b/lib/internal/util.js index a87bc68e7693e1..b125e7f76e61d7 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -2,7 +2,7 @@ const errors = require('internal/errors'); const binding = process.binding('util'); -const signals = process.binding('constants').os.signals; +const { signals } = process.binding('constants').os; const { createPromise, promiseResolve, promiseReject } = binding; diff --git a/lib/module.js b/lib/module.js index beeddc87941cb0..ef5b3fe4c34ae0 100644 --- a/lib/module.js +++ b/lib/module.js @@ -30,8 +30,10 @@ const assert = require('assert').ok; const fs = require('fs'); const internalFS = require('internal/fs'); const path = require('path'); -const internalModuleReadFile = process.binding('fs').internalModuleReadFile; -const internalModuleStat = process.binding('fs').internalModuleStat; +const { + internalModuleReadFile, + internalModuleStat +} = process.binding('fs'); const preserveSymlinks = !!process.binding('config').preserveSymlinks; const experimentalModules = !!process.binding('config').experimentalModules; diff --git a/lib/net.js b/lib/net.js index ba67c3d2efaad9..753bc42e6d2629 100644 --- a/lib/net.js +++ b/lib/net.js @@ -26,22 +26,21 @@ const stream = require('stream'); const timers = require('timers'); const util = require('util'); const internalUtil = require('internal/util'); -const internalNet = require('internal/net'); +const { isLegalPort, normalizedArgsSymbol } = require('internal/net'); const assert = require('assert'); const cares = process.binding('cares_wrap'); const uv = process.binding('uv'); -const Buffer = require('buffer').Buffer; +const { Buffer } = require('buffer'); const TTYWrap = process.binding('tty_wrap'); -const TCP = process.binding('tcp_wrap').TCP; -const Pipe = process.binding('pipe_wrap').Pipe; -const TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap; -const PipeConnectWrap = process.binding('pipe_wrap').PipeConnectWrap; -const ShutdownWrap = process.binding('stream_wrap').ShutdownWrap; -const WriteWrap = process.binding('stream_wrap').WriteWrap; -const async_id_symbol = process.binding('async_wrap').async_id_symbol; +const { TCP } = process.binding('tcp_wrap'); +const { Pipe } = process.binding('pipe_wrap'); +const { TCPConnectWrap } = process.binding('tcp_wrap'); +const { PipeConnectWrap } = process.binding('pipe_wrap'); +const { ShutdownWrap, WriteWrap } = process.binding('stream_wrap'); +const { async_id_symbol } = process.binding('async_wrap'); const { newUid, setInitTriggerId } = require('async_hooks'); -const nextTick = require('internal/process/next_tick').nextTick; +const { nextTick } = require('internal/process/next_tick'); const errors = require('internal/errors'); const dns = require('dns'); @@ -51,8 +50,6 @@ var cluster = null; const errnoException = util._errnoException; const exceptionWithHostPort = util._exceptionWithHostPort; -const isLegalPort = internalNet.isLegalPort; -const normalizedArgsSymbol = internalNet.normalizedArgsSymbol; function noop() {} diff --git a/lib/os.js b/lib/os.js index 078dba3fcca071..bf843ba0a86281 100644 --- a/lib/os.js +++ b/lib/os.js @@ -21,10 +21,10 @@ 'use strict'; -const pushValToArrayMax = process.binding('util').pushValToArrayMax; +const { pushValToArrayMax } = process.binding('util'); const constants = process.binding('constants').os; -const deprecate = require('internal/util').deprecate; -const getCIDRSuffix = require('internal/os').getCIDRSuffix; +const { deprecate } = require('internal/util'); +const { getCIDRSuffix } = require('internal/os'); const isWindows = process.platform === 'win32'; const { diff --git a/lib/readline.js b/lib/readline.js index 90891542421c15..fa9cc188e1483c 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -47,7 +47,7 @@ const { kClearScreenDown } = CSI; -const now = process.binding('timer_wrap').Timer.now; +const { now } = process.binding('timer_wrap').Timer; const kHistorySize = 30; const kMincrlfDelay = 100; diff --git a/lib/repl.js b/lib/repl.js index 0b49434bfea959..4c3e5af4d6ec8e 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -47,13 +47,13 @@ const internalUtil = require('internal/util'); const { isTypedArray } = require('internal/util/types'); const util = require('util'); const utilBinding = process.binding('util'); -const inherits = util.inherits; +const { inherits } = util; const Stream = require('stream'); const vm = require('vm'); const path = require('path'); const fs = require('fs'); -const Interface = require('readline').Interface; -const Console = require('console').Console; +const { Interface } = require('readline'); +const { Console } = require('console'); const Module = require('module'); const domain = require('domain'); const debug = util.debuglog('repl'); diff --git a/lib/stream.js b/lib/stream.js index 0dd44e3a61e88f..edc5f231b83411 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -21,7 +21,7 @@ 'use strict'; -const Buffer = require('buffer').Buffer; +const { Buffer } = require('buffer'); // Note: export Stream before Readable/Writable/Duplex/... // to avoid a cross-reference(require) issues diff --git a/lib/string_decoder.js b/lib/string_decoder.js index eee9a7d9273ebf..5e60bf1ad1c3d7 100644 --- a/lib/string_decoder.js +++ b/lib/string_decoder.js @@ -21,7 +21,7 @@ 'use strict'; -const Buffer = require('buffer').Buffer; +const { Buffer } = require('buffer'); const internalUtil = require('internal/util'); const isEncoding = Buffer[internalUtil.kIsEncodingSymbol]; diff --git a/lib/timers.js b/lib/timers.js index 51ef6d60096f07..8e45eeb9d81e0d 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -26,16 +26,20 @@ const TimerWrap = process.binding('timer_wrap').Timer; const L = require('internal/linkedlist'); const internalUtil = require('internal/util'); const { createPromise, promiseResolve } = process.binding('util'); -const async_hooks = require('async_hooks'); const assert = require('assert'); const util = require('util'); const debug = util.debuglog('timer'); const kOnTimeout = TimerWrap.kOnTimeout | 0; -const initTriggerId = async_hooks.initTriggerId; // Two arrays that share state between C++ and JS. const { async_hook_fields, async_id_fields } = async_wrap; -// The needed emit*() functions. -const { emitInit, emitBefore, emitAfter, emitDestroy } = async_hooks; +const { + initTriggerId, + // The needed emit*() functions. + emitInit, + emitBefore, + emitAfter, + emitDestroy +} = require('async_hooks'); // Grab the constants necessary for working with internal arrays. const { kInit, kDestroy, kAsyncIdCounter } = async_wrap.constants; // Symbols for storing async id state. diff --git a/lib/tty.js b/lib/tty.js index c8606491d8b0b1..cf020f529dae71 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -23,9 +23,8 @@ const util = require('util'); const net = require('net'); -const TTY = process.binding('tty_wrap').TTY; -const isTTY = process.binding('tty_wrap').isTTY; -const inherits = util.inherits; +const { TTY, isTTY } = process.binding('tty_wrap'); +const { inherits } = util; const errnoException = util._errnoException; const errors = require('internal/errors'); const readline = require('readline');