Browse Source

lib: use destructuring for some constants

This change is to unify the declaration for constants into using
destructuring on the top-level-module scope, reducing some redundant
code.

PR-URL: https://github.com/nodejs/node/pull/16063
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
v9.x-staging
Weijia Wang 7 years ago
committed by Tobias Nießen
parent
commit
212de3c5ec
No known key found for this signature in database GPG Key ID: 718207F8FD156B70
  1. 4
      lib/_http_agent.js
  2. 24
      lib/_http_client.js
  3. 15
      lib/_http_common.js
  4. 13
      lib/_http_outgoing.js
  5. 24
      lib/_http_server.js
  6. 2
      lib/_stream_readable.js
  7. 4
      lib/_stream_wrap.js
  8. 2
      lib/_stream_writable.js
  9. 3
      lib/_tls_common.js
  10. 6
      lib/_tls_legacy.js
  11. 10
      lib/_tls_wrap.js
  12. 14
      lib/child_process.js
  13. 13
      lib/dgram.js
  14. 5
      lib/dns.js
  15. 2
      lib/domain.js
  16. 22
      lib/fs.js
  17. 5
      lib/http.js
  18. 2
      lib/https.js
  19. 17
      lib/internal/child_process.js
  20. 2
      lib/internal/cluster/master.js
  21. 4
      lib/internal/fs.js
  22. 2
      lib/internal/http2/core.js
  23. 4
      lib/internal/process/write-coverage.js
  24. 2
      lib/internal/repl.js
  25. 2
      lib/internal/streams/BufferList.js
  26. 2
      lib/internal/util.js
  27. 6
      lib/module.js
  28. 21
      lib/net.js
  29. 6
      lib/os.js
  30. 2
      lib/readline.js
  31. 6
      lib/repl.js
  32. 2
      lib/stream.js
  33. 2
      lib/string_decoder.js
  34. 12
      lib/timers.js
  35. 5
      lib/tty.js

4
lib/_http_agent.js

@ -25,8 +25,8 @@ const net = require('net');
const util = require('util'); const util = require('util');
const EventEmitter = require('events'); const EventEmitter = require('events');
const debug = util.debuglog('http'); const debug = util.debuglog('http');
const async_id_symbol = process.binding('async_wrap').async_id_symbol; const { async_id_symbol } = process.binding('async_wrap');
const nextTick = require('internal/process/next_tick').nextTick; const { nextTick } = require('internal/process/next_tick');
// New Agent code. // New Agent code.

24
lib/_http_client.js

@ -24,19 +24,21 @@
const util = require('util'); const util = require('util');
const net = require('net'); const net = require('net');
const url = require('url'); const url = require('url');
const HTTPParser = process.binding('http_parser').HTTPParser; const { HTTPParser } = process.binding('http_parser');
const assert = require('assert').ok; const assert = require('assert').ok;
const common = require('_http_common'); const {
const httpSocketSetup = common.httpSocketSetup; _checkIsHttpToken: checkIsHttpToken,
const parsers = common.parsers; debug,
const freeParser = common.freeParser; freeParser,
const debug = common.debug; httpSocketSetup,
const OutgoingMessage = require('_http_outgoing').OutgoingMessage; parsers
} = require('_http_common');
const { OutgoingMessage } = require('_http_outgoing');
const Agent = require('_http_agent'); const Agent = require('_http_agent');
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
const { urlToOptions, searchParamsSymbol } = require('internal/url'); const { urlToOptions, searchParamsSymbol } = require('internal/url');
const outHeadersKey = require('internal/http').outHeadersKey; const { outHeadersKey } = require('internal/http');
const nextTick = require('internal/process/next_tick').nextTick; const { nextTick } = require('internal/process/next_tick');
const errors = require('internal/errors'); const errors = require('internal/errors');
// The actual list of disallowed characters in regexp form is more like: // The actual list of disallowed characters in regexp form is more like:
@ -149,7 +151,7 @@ function ClientRequest(options, cb) {
} }
if (methodIsString && method) { if (methodIsString && method) {
if (!common._checkIsHttpToken(method)) { if (!checkIsHttpToken(method)) {
throw new errors.TypeError('ERR_INVALID_HTTP_TOKEN', 'Method', method); throw new errors.TypeError('ERR_INVALID_HTTP_TOKEN', 'Method', method);
} }
method = this.method = method.toUpperCase(); method = this.method = method.toUpperCase();

15
lib/_http_common.js

@ -22,16 +22,17 @@
'use strict'; 'use strict';
const binding = process.binding('http_parser'); const binding = process.binding('http_parser');
const methods = binding.methods; const { methods, HTTPParser } = binding;
const HTTPParser = binding.HTTPParser;
const FreeList = require('internal/freelist'); const FreeList = require('internal/freelist');
const ondrain = require('internal/http').ondrain; const { ondrain } = require('internal/http');
const incoming = require('_http_incoming'); const incoming = require('_http_incoming');
const emitDestroy = require('async_hooks').emitDestroy; const { emitDestroy } = require('async_hooks');
const IncomingMessage = incoming.IncomingMessage; const {
const readStart = incoming.readStart; IncomingMessage,
const readStop = incoming.readStop; readStart,
readStop
} = incoming;
const debug = require('util').debuglog('http'); const debug = require('util').debuglog('http');

13
lib/_http_outgoing.js

@ -26,18 +26,17 @@ const Stream = require('stream');
const util = require('util'); const util = require('util');
const internalUtil = require('internal/util'); const internalUtil = require('internal/util');
const internalHttp = require('internal/http'); const internalHttp = require('internal/http');
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
const common = require('_http_common'); const common = require('_http_common');
const checkIsHttpToken = common._checkIsHttpToken; const checkIsHttpToken = common._checkIsHttpToken;
const checkInvalidHeaderChar = common._checkInvalidHeaderChar; const checkInvalidHeaderChar = common._checkInvalidHeaderChar;
const outHeadersKey = require('internal/http').outHeadersKey; const { outHeadersKey } = require('internal/http');
const async_id_symbol = process.binding('async_wrap').async_id_symbol; const { async_id_symbol } = process.binding('async_wrap');
const nextTick = require('internal/process/next_tick').nextTick; const { nextTick } = require('internal/process/next_tick');
const errors = require('internal/errors'); const errors = require('internal/errors');
const CRLF = common.CRLF; const { CRLF, debug } = common;
const debug = common.debug; const { utcDate } = internalHttp;
const utcDate = internalHttp.utcDate;
var RE_FIELDS = var RE_FIELDS =
/^(?:Connection|Transfer-Encoding|Content-Length|Date|Expect|Trailer|Upgrade)$/i; /^(?:Connection|Transfer-Encoding|Content-Length|Date|Expect|Trailer|Upgrade)$/i;

24
lib/_http_server.js

@ -23,17 +23,19 @@
const util = require('util'); const util = require('util');
const net = require('net'); const net = require('net');
const HTTPParser = process.binding('http_parser').HTTPParser; const { HTTPParser } = process.binding('http_parser');
const assert = require('assert').ok; const assert = require('assert').ok;
const common = require('_http_common'); const {
const parsers = common.parsers; parsers,
const freeParser = common.freeParser; freeParser,
const debug = common.debug; debug,
const CRLF = common.CRLF; CRLF,
const continueExpression = common.continueExpression; continueExpression,
const chunkExpression = common.chunkExpression; chunkExpression,
const httpSocketSetup = common.httpSocketSetup; httpSocketSetup,
const OutgoingMessage = require('_http_outgoing').OutgoingMessage; _checkInvalidHeaderChar: checkInvalidHeaderChar
} = require('_http_common');
const { OutgoingMessage } = require('_http_outgoing');
const { outHeadersKey, ondrain } = require('internal/http'); const { outHeadersKey, ondrain } = require('internal/http');
const errors = require('internal/errors'); const errors = require('internal/errors');
@ -223,7 +225,7 @@ function writeHead(statusCode, reason, obj) {
headers = obj; headers = obj;
} }
if (common._checkInvalidHeaderChar(this.statusMessage)) if (checkInvalidHeaderChar(this.statusMessage))
throw new errors.Error('ERR_INVALID_CHAR', 'statusMessage'); throw new errors.Error('ERR_INVALID_CHAR', 'statusMessage');
var statusLine = 'HTTP/1.1 ' + statusCode + ' ' + this.statusMessage + CRLF; var statusLine = 'HTTP/1.1 ' + statusCode + ' ' + this.statusMessage + CRLF;

2
lib/_stream_readable.js

@ -26,7 +26,7 @@ Readable.ReadableState = ReadableState;
const EE = require('events'); const EE = require('events');
const Stream = require('stream'); const Stream = require('stream');
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
const util = require('util'); const util = require('util');
const debug = util.debuglog('stream'); const debug = util.debuglog('stream');
const BufferList = require('internal/streams/BufferList'); const BufferList = require('internal/streams/BufferList');

4
lib/_stream_wrap.js

@ -2,8 +2,8 @@
const assert = require('assert'); const assert = require('assert');
const util = require('util'); const util = require('util');
const Socket = require('net').Socket; const { Socket } = require('net');
const JSStream = process.binding('js_stream').JSStream; const { JSStream } = process.binding('js_stream');
const uv = process.binding('uv'); const uv = process.binding('uv');
const debug = util.debuglog('stream_wrap'); const debug = util.debuglog('stream_wrap');
const errors = require('internal/errors'); const errors = require('internal/errors');

2
lib/_stream_writable.js

@ -31,7 +31,7 @@ Writable.WritableState = WritableState;
const util = require('util'); const util = require('util');
const internalUtil = require('internal/util'); const internalUtil = require('internal/util');
const Stream = require('stream'); const Stream = require('stream');
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
const destroyImpl = require('internal/streams/destroy'); const destroyImpl = require('internal/streams/destroy');
const errors = require('internal/errors'); const errors = require('internal/errors');

3
lib/_tls_common.js

@ -26,8 +26,7 @@ const { isArrayBufferView } = require('internal/util/types');
const tls = require('tls'); const tls = require('tls');
const errors = require('internal/errors'); const errors = require('internal/errors');
const SSL_OP_CIPHER_SERVER_PREFERENCE = const { SSL_OP_CIPHER_SERVER_PREFERENCE } = process.binding('constants').crypto;
process.binding('constants').crypto.SSL_OP_CIPHER_SERVER_PREFERENCE;
// Lazily loaded // Lazily loaded
var crypto = null; var crypto = null;

6
lib/_tls_legacy.js

@ -25,12 +25,12 @@ const internalUtil = require('internal/util');
internalUtil.assertCrypto(); internalUtil.assertCrypto();
const assert = require('assert'); const assert = require('assert');
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
const common = require('_tls_common'); const common = require('_tls_common');
const Connection = process.binding('crypto').Connection; const { Connection } = process.binding('crypto');
const EventEmitter = require('events'); const EventEmitter = require('events');
const stream = require('stream'); const stream = require('stream');
const Timer = process.binding('timer_wrap').Timer; const { Timer } = process.binding('timer_wrap');
const tls = require('tls'); const tls = require('tls');
const util = require('util'); const util = require('util');

10
lib/_tls_wrap.js

@ -29,13 +29,13 @@ const net = require('net');
const tls = require('tls'); const tls = require('tls');
const util = require('util'); const util = require('util');
const common = require('_tls_common'); const common = require('_tls_common');
const StreamWrap = require('_stream_wrap').StreamWrap; const { StreamWrap } = require('_stream_wrap');
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
const debug = util.debuglog('tls'); 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 tls_wrap = process.binding('tls_wrap');
const TCP = process.binding('tcp_wrap').TCP; const { TCP } = process.binding('tcp_wrap');
const Pipe = process.binding('pipe_wrap').Pipe; const { Pipe } = process.binding('pipe_wrap');
const errors = require('internal/errors'); const errors = require('internal/errors');
const kConnectOptions = Symbol('connect-options'); const kConnectOptions = Symbol('connect-options');
const kDisableRenegotiation = Symbol('disable-renegotiation'); const kDisableRenegotiation = Symbol('disable-renegotiation');

14
lib/child_process.js

@ -27,15 +27,17 @@ const { isUint8Array } = require('internal/util/types');
const { createPromise, const { createPromise,
promiseResolve, promiseReject } = process.binding('util'); promiseResolve, promiseReject } = process.binding('util');
const debug = util.debuglog('child_process'); const debug = util.debuglog('child_process');
const { Buffer } = require('buffer');
const Buffer = require('buffer').Buffer; const { Pipe } = process.binding('pipe_wrap');
const Pipe = process.binding('pipe_wrap').Pipe;
const { errname } = process.binding('uv'); const { errname } = process.binding('uv');
const child_process = require('internal/child_process'); const child_process = require('internal/child_process');
const {
_validateStdio,
setupChannel,
ChildProcess
} = child_process;
const _validateStdio = child_process._validateStdio; exports.ChildProcess = ChildProcess;
const setupChannel = child_process.setupChannel;
const ChildProcess = exports.ChildProcess = child_process.ChildProcess;
function stdioStringToArray(option) { function stdioStringToArray(option) {
switch (option) { switch (option) {

13
lib/dgram.js

@ -23,18 +23,17 @@
const assert = require('assert'); const assert = require('assert');
const errors = require('internal/errors'); const errors = require('internal/errors');
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
const dns = require('dns'); const dns = require('dns');
const util = require('util'); const util = require('util');
const { isUint8Array } = require('internal/util/types'); const { isUint8Array } = require('internal/util/types');
const EventEmitter = require('events'); const EventEmitter = require('events');
const setInitTriggerId = require('async_hooks').setInitTriggerId; const { setInitTriggerId } = require('async_hooks');
const UV_UDP_REUSEADDR = process.binding('constants').os.UV_UDP_REUSEADDR; const { UV_UDP_REUSEADDR } = process.binding('constants').os;
const async_id_symbol = process.binding('async_wrap').async_id_symbol; const { async_id_symbol } = process.binding('async_wrap');
const nextTick = require('internal/process/next_tick').nextTick; const { nextTick } = require('internal/process/next_tick');
const UDP = process.binding('udp_wrap').UDP; const { UDP, SendWrap } = process.binding('udp_wrap');
const SendWrap = process.binding('udp_wrap').SendWrap;
const BIND_STATE_UNBOUND = 0; const BIND_STATE_UNBOUND = 0;
const BIND_STATE_BINDING = 1; const BIND_STATE_BINDING = 1;

5
lib/dns.js

@ -24,7 +24,7 @@
const util = require('util'); const util = require('util');
const cares = process.binding('cares_wrap'); const cares = process.binding('cares_wrap');
const internalNet = require('internal/net'); const { isLegalPort } = require('internal/net');
const { customPromisifyArgs } = require('internal/util'); const { customPromisifyArgs } = require('internal/util');
const errors = require('internal/errors'); const errors = require('internal/errors');
const { const {
@ -41,9 +41,6 @@ const {
isIP isIP
} = cares; } = cares;
const isLegalPort = internalNet.isLegalPort;
function errnoException(err, syscall, hostname) { function errnoException(err, syscall, hostname) {
// FIXME(bnoordhuis) Remove this backwards compatibility nonsense and pass // FIXME(bnoordhuis) Remove this backwards compatibility nonsense and pass
// the true error to the user. ENOTFOUND is not even a proper POSIX error! // the true error to the user. ENOTFOUND is not even a proper POSIX error!

2
lib/domain.js

@ -28,7 +28,7 @@
const util = require('util'); const util = require('util');
const EventEmitter = require('events'); const EventEmitter = require('events');
const inherits = util.inherits; const { inherits } = util;
// communicate with events module, but don't require that // communicate with events module, but don't require that
// module to have to load this one, since this module has // module to have to load this one, since this module has

22
lib/fs.js

@ -33,18 +33,19 @@ const { createPromise, promiseResolve } = process.binding('util');
const binding = process.binding('fs'); const binding = process.binding('fs');
const fs = exports; const fs = exports;
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
const errors = require('internal/errors'); const errors = require('internal/errors');
const Stream = require('stream').Stream; const { Readable, Writable } = require('stream');
const EventEmitter = require('events'); const EventEmitter = require('events');
const FSReqWrap = binding.FSReqWrap; const { FSReqWrap } = binding;
const FSEvent = process.binding('fs_event_wrap').FSEvent; const { FSEvent } = process.binding('fs_event_wrap');
const internalFS = require('internal/fs'); const internalFS = require('internal/fs');
const internalURL = require('internal/url'); const { getPathFromURL } = require('internal/url');
const internalUtil = require('internal/util'); const internalUtil = require('internal/util');
const assertEncoding = internalFS.assertEncoding; const {
const stringToFlags = internalFS.stringToFlags; assertEncoding,
const getPathFromURL = internalURL.getPathFromURL; stringToFlags
} = internalFS;
Object.defineProperty(exports, 'constants', { Object.defineProperty(exports, 'constants', {
configurable: false, configurable: false,
@ -52,11 +53,8 @@ Object.defineProperty(exports, 'constants', {
value: constants value: constants
}); });
const Readable = Stream.Readable;
const Writable = Stream.Writable;
const kMinPoolSpace = 128; const kMinPoolSpace = 128;
const kMaxLength = require('buffer').kMaxLength; const { kMaxLength } = require('buffer');
const isWindows = process.platform === 'win32'; const isWindows = process.platform === 'win32';

5
lib/http.js

@ -22,14 +22,13 @@
'use strict'; 'use strict';
const agent = require('_http_agent'); const agent = require('_http_agent');
const client = require('_http_client'); const { ClientRequest } = require('_http_client');
const common = require('_http_common'); const common = require('_http_common');
const incoming = require('_http_incoming'); const incoming = require('_http_incoming');
const outgoing = require('_http_outgoing'); const outgoing = require('_http_outgoing');
const server = require('_http_server'); const server = require('_http_server');
const Server = server.Server; const { Server } = server;
const ClientRequest = client.ClientRequest;
function createServer(requestListener) { function createServer(requestListener) {
return new Server(requestListener); return new Server(requestListener);

2
lib/https.js

@ -27,7 +27,7 @@ const tls = require('tls');
const url = require('url'); const url = require('url');
const http = require('http'); const http = require('http');
const util = require('util'); const util = require('util');
const inherits = util.inherits; const { inherits } = util;
const debug = util.debuglog('https'); const debug = util.debuglog('https');
const { urlToOptions, searchParamsSymbol } = require('internal/url'); const { urlToOptions, searchParamsSymbol } = require('internal/url');
const errors = require('internal/errors'); const errors = require('internal/errors');

17
lib/internal/child_process.js

@ -1,19 +1,19 @@
'use strict'; 'use strict';
const errors = require('internal/errors'); const errors = require('internal/errors');
const StringDecoder = require('string_decoder').StringDecoder; const { StringDecoder } = require('string_decoder');
const EventEmitter = require('events'); const EventEmitter = require('events');
const net = require('net'); const net = require('net');
const dgram = require('dgram'); const dgram = require('dgram');
const util = require('util'); const util = require('util');
const assert = require('assert'); const assert = require('assert');
const Process = process.binding('process_wrap').Process; const { Process } = process.binding('process_wrap');
const WriteWrap = process.binding('stream_wrap').WriteWrap; const { WriteWrap } = process.binding('stream_wrap');
const Pipe = process.binding('pipe_wrap').Pipe; const { Pipe } = process.binding('pipe_wrap');
const TTY = process.binding('tty_wrap').TTY; const { TTY } = process.binding('tty_wrap');
const TCP = process.binding('tcp_wrap').TCP; const { TCP } = process.binding('tcp_wrap');
const UDP = process.binding('udp_wrap').UDP; const { UDP } = process.binding('udp_wrap');
const SocketList = require('internal/socket_list'); const SocketList = require('internal/socket_list');
const { convertToValidSignal } = require('internal/util'); const { convertToValidSignal } = require('internal/util');
const { isUint8Array } = require('internal/util/types'); const { isUint8Array } = require('internal/util/types');
@ -30,8 +30,7 @@ const {
} = process.binding('uv'); } = process.binding('uv');
const errnoException = util._errnoException; const errnoException = util._errnoException;
const SocketListSend = SocketList.SocketListSend; const { SocketListSend, SocketListReceive } = SocketList;
const SocketListReceive = SocketList.SocketListReceive;
const MAX_HANDLE_RETRANSMISSIONS = 3; const MAX_HANDLE_RETRANSMISSIONS = 3;

2
lib/internal/cluster/master.js

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const assert = require('assert'); const assert = require('assert');
const fork = require('child_process').fork; const { fork } = require('child_process');
const util = require('util'); const util = require('util');
const EventEmitter = require('events'); const EventEmitter = require('events');
const RoundRobinHandle = require('internal/cluster/round_robin_handle'); const RoundRobinHandle = require('internal/cluster/round_robin_handle');

4
lib/internal/fs.js

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
const Writable = require('stream').Writable; const { Writable } = require('stream');
const errors = require('internal/errors'); const errors = require('internal/errors');
const fs = require('fs'); const fs = require('fs');
const util = require('util'); const util = require('util');

2
lib/internal/http2/core.js

@ -6,7 +6,7 @@ require('internal/util').assertCrypto();
const binding = process.binding('http2'); const binding = process.binding('http2');
const assert = require('assert'); const assert = require('assert');
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
const EventEmitter = require('events'); const EventEmitter = require('events');
const net = require('net'); const net = require('net');
const tls = require('tls'); const tls = require('tls');

4
lib/internal/process/write-coverage.js

@ -1,9 +1,7 @@
'use strict'; 'use strict';
const process = require('process'); const process = require('process');
const path = require('path'); const path = require('path');
const fs = require('fs'); const { mkdirSync, writeFileSync } = require('fs');
const mkdirSync = fs.mkdirSync;
const writeFileSync = fs.writeFileSync;
function writeCoverage() { function writeCoverage() {
if (!global.__coverage__) { if (!global.__coverage__) {

2
lib/internal/repl.js

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const Interface = require('readline').Interface; const { Interface } = require('readline');
const REPL = require('repl'); const REPL = require('repl');
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');

2
lib/internal/streams/BufferList.js

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
function copyBuffer(src, target, offset) { function copyBuffer(src, target, offset) {
Buffer.prototype.copy.call(src, target, offset); Buffer.prototype.copy.call(src, target, offset);

2
lib/internal/util.js

@ -2,7 +2,7 @@
const errors = require('internal/errors'); const errors = require('internal/errors');
const binding = process.binding('util'); const binding = process.binding('util');
const signals = process.binding('constants').os.signals; const { signals } = process.binding('constants').os;
const { createPromise, promiseResolve, promiseReject } = binding; const { createPromise, promiseResolve, promiseReject } = binding;

6
lib/module.js

@ -30,8 +30,10 @@ const assert = require('assert').ok;
const fs = require('fs'); const fs = require('fs');
const internalFS = require('internal/fs'); const internalFS = require('internal/fs');
const path = require('path'); const path = require('path');
const internalModuleReadFile = process.binding('fs').internalModuleReadFile; const {
const internalModuleStat = process.binding('fs').internalModuleStat; internalModuleReadFile,
internalModuleStat
} = process.binding('fs');
const preserveSymlinks = !!process.binding('config').preserveSymlinks; const preserveSymlinks = !!process.binding('config').preserveSymlinks;
const experimentalModules = !!process.binding('config').experimentalModules; const experimentalModules = !!process.binding('config').experimentalModules;

21
lib/net.js

@ -26,7 +26,7 @@ const stream = require('stream');
const timers = require('timers'); const timers = require('timers');
const util = require('util'); const util = require('util');
const internalUtil = require('internal/util'); const internalUtil = require('internal/util');
const internalNet = require('internal/net'); const { isLegalPort, normalizedArgsSymbol } = require('internal/net');
const assert = require('assert'); const assert = require('assert');
const cares = process.binding('cares_wrap'); const cares = process.binding('cares_wrap');
const { const {
@ -35,17 +35,16 @@ const {
UV_EOF UV_EOF
} = process.binding('uv'); } = process.binding('uv');
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
const TTYWrap = process.binding('tty_wrap'); const TTYWrap = process.binding('tty_wrap');
const TCP = process.binding('tcp_wrap').TCP; const { TCP } = process.binding('tcp_wrap');
const Pipe = process.binding('pipe_wrap').Pipe; const { Pipe } = process.binding('pipe_wrap');
const TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap; const { TCPConnectWrap } = process.binding('tcp_wrap');
const PipeConnectWrap = process.binding('pipe_wrap').PipeConnectWrap; const { PipeConnectWrap } = process.binding('pipe_wrap');
const ShutdownWrap = process.binding('stream_wrap').ShutdownWrap; const { ShutdownWrap, WriteWrap } = process.binding('stream_wrap');
const WriteWrap = process.binding('stream_wrap').WriteWrap; const { async_id_symbol } = process.binding('async_wrap');
const async_id_symbol = process.binding('async_wrap').async_id_symbol;
const { newUid, setInitTriggerId } = require('async_hooks'); 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 errors = require('internal/errors');
const dns = require('dns'); const dns = require('dns');
@ -55,8 +54,6 @@ var cluster = null;
const errnoException = util._errnoException; const errnoException = util._errnoException;
const exceptionWithHostPort = util._exceptionWithHostPort; const exceptionWithHostPort = util._exceptionWithHostPort;
const isLegalPort = internalNet.isLegalPort;
const normalizedArgsSymbol = internalNet.normalizedArgsSymbol;
function noop() {} function noop() {}

6
lib/os.js

@ -21,10 +21,10 @@
'use strict'; 'use strict';
const pushValToArrayMax = process.binding('util').pushValToArrayMax; const { pushValToArrayMax } = process.binding('util');
const constants = process.binding('constants').os; const constants = process.binding('constants').os;
const deprecate = require('internal/util').deprecate; const { deprecate } = require('internal/util');
const getCIDRSuffix = require('internal/os').getCIDRSuffix; const { getCIDRSuffix } = require('internal/os');
const isWindows = process.platform === 'win32'; const isWindows = process.platform === 'win32';
const { const {

2
lib/readline.js

@ -48,7 +48,7 @@ const {
kClearScreenDown kClearScreenDown
} = CSI; } = CSI;
const now = process.binding('timer_wrap').Timer.now; const { now } = process.binding('timer_wrap').Timer;
const kHistorySize = 30; const kHistorySize = 30;
const kMincrlfDelay = 100; const kMincrlfDelay = 100;

6
lib/repl.js

@ -47,13 +47,13 @@ const internalUtil = require('internal/util');
const { isTypedArray } = require('internal/util/types'); const { isTypedArray } = require('internal/util/types');
const util = require('util'); const util = require('util');
const utilBinding = process.binding('util'); const utilBinding = process.binding('util');
const inherits = util.inherits; const { inherits } = util;
const Stream = require('stream'); const Stream = require('stream');
const vm = require('vm'); const vm = require('vm');
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const Interface = require('readline').Interface; const { Interface } = require('readline');
const Console = require('console').Console; const { Console } = require('console');
const Module = require('module'); const Module = require('module');
const domain = require('domain'); const domain = require('domain');
const debug = util.debuglog('repl'); const debug = util.debuglog('repl');

2
lib/stream.js

@ -21,7 +21,7 @@
'use strict'; 'use strict';
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
// Note: export Stream before Readable/Writable/Duplex/... // Note: export Stream before Readable/Writable/Duplex/...
// to avoid a cross-reference(require) issues // to avoid a cross-reference(require) issues

2
lib/string_decoder.js

@ -21,7 +21,7 @@
'use strict'; 'use strict';
const Buffer = require('buffer').Buffer; const { Buffer } = require('buffer');
const internalUtil = require('internal/util'); const internalUtil = require('internal/util');
const errors = require('internal/errors'); const errors = require('internal/errors');
const isEncoding = Buffer[internalUtil.kIsEncodingSymbol]; const isEncoding = Buffer[internalUtil.kIsEncodingSymbol];

12
lib/timers.js

@ -26,17 +26,21 @@ const TimerWrap = process.binding('timer_wrap').Timer;
const L = require('internal/linkedlist'); const L = require('internal/linkedlist');
const internalUtil = require('internal/util'); const internalUtil = require('internal/util');
const { createPromise, promiseResolve } = process.binding('util'); const { createPromise, promiseResolve } = process.binding('util');
const async_hooks = require('async_hooks');
const assert = require('assert'); const assert = require('assert');
const util = require('util'); const util = require('util');
const errors = require('internal/errors'); const errors = require('internal/errors');
const debug = util.debuglog('timer'); const debug = util.debuglog('timer');
const kOnTimeout = TimerWrap.kOnTimeout | 0; const kOnTimeout = TimerWrap.kOnTimeout | 0;
const initTriggerId = async_hooks.initTriggerId;
// Two arrays that share state between C++ and JS. // Two arrays that share state between C++ and JS.
const { async_hook_fields, async_id_fields } = async_wrap; const { async_hook_fields, async_id_fields } = async_wrap;
// The needed emit*() functions. const {
const { emitInit, emitBefore, emitAfter, emitDestroy } = async_hooks; initTriggerId,
// The needed emit*() functions.
emitInit,
emitBefore,
emitAfter,
emitDestroy
} = require('async_hooks');
// Grab the constants necessary for working with internal arrays. // Grab the constants necessary for working with internal arrays.
const { kInit, kDestroy, kAsyncIdCounter } = async_wrap.constants; const { kInit, kDestroy, kAsyncIdCounter } = async_wrap.constants;
// Symbols for storing async id state. // Symbols for storing async id state.

5
lib/tty.js

@ -23,9 +23,8 @@
const util = require('util'); const util = require('util');
const net = require('net'); const net = require('net');
const TTY = process.binding('tty_wrap').TTY; const { TTY, isTTY } = process.binding('tty_wrap');
const isTTY = process.binding('tty_wrap').isTTY; const { inherits } = util;
const inherits = util.inherits;
const errnoException = util._errnoException; const errnoException = util._errnoException;
const errors = require('internal/errors'); const errors = require('internal/errors');
const readline = require('readline'); const readline = require('readline');

Loading…
Cancel
Save