diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index a1a0b9490a9177..65c7c88ba0cbe7 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -44,3 +44,4 @@ globals: DCHECK_LE: false DCHECK_LT: false DCHECK_NE: false + internalBinding: false diff --git a/lib/_http_client.js b/lib/_http_client.js index 462245174ed6f6..c8c671ccfc418e 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -24,7 +24,7 @@ const util = require('util'); const net = require('net'); const url = require('url'); -const { HTTPParser } = process.binding('http_parser'); +const { HTTPParser } = internalBinding('http_parser'); const assert = require('assert').ok; const { _checkIsHttpToken: checkIsHttpToken, diff --git a/lib/_http_common.js b/lib/_http_common.js index 49fd7a59650dc6..10e8b63bfed75d 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -21,7 +21,7 @@ 'use strict'; -const { methods, HTTPParser } = process.binding('http_parser'); +const { methods, HTTPParser } = internalBinding('http_parser'); const FreeList = require('internal/freelist'); const { ondrain } = require('internal/http'); diff --git a/lib/_http_server.js b/lib/_http_server.js index db12980697b1dd..805697e367529c 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -23,7 +23,7 @@ const util = require('util'); const net = require('net'); -const { HTTPParser } = process.binding('http_parser'); +const { HTTPParser } = internalBinding('http_parser'); const assert = require('assert').ok; const { parsers, diff --git a/lib/_tls_common.js b/lib/_tls_common.js index 60995278a37857..1073f5d520e0b9 100644 --- a/lib/_tls_common.js +++ b/lib/_tls_common.js @@ -34,7 +34,7 @@ const { SSL_OP_CIPHER_SERVER_PREFERENCE } = process.binding('constants').crypto; // Lazily loaded var crypto = null; -const { SecureContext: NativeSecureContext } = process.binding('crypto'); +const { SecureContext: NativeSecureContext } = internalBinding('crypto'); function SecureContext(secureProtocol, secureOptions, context) { if (!(this instanceof SecureContext)) { diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 0c3c0e3cfcbf7b..d6f1480040bd3b 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -32,9 +32,9 @@ const common = require('_tls_common'); const { StreamWrap } = require('_stream_wrap'); const { Buffer } = require('buffer'); const debug = util.debuglog('tls'); -const tls_wrap = process.binding('tls_wrap'); -const { TCP, constants: TCPConstants } = process.binding('tcp_wrap'); -const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap'); +const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap'); +const tls_wrap = internalBinding('tls_wrap'); +const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); const { owner_symbol } = require('internal/async_hooks').symbols; const { SecureContext: NativeSecureContext diff --git a/lib/buffer.js b/lib/buffer.js index c603d20b6f088c..645ba7af9bc3fe 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -41,7 +41,6 @@ const { // that test/parallel/test-buffer-bindingobj-no-zerofill.js is written. let isAnyArrayBuffer; try { - const { internalBinding } = require('internal/bootstrap/loaders'); isAnyArrayBuffer = internalBinding('types').isAnyArrayBuffer; } catch (e) { isAnyArrayBuffer = require('util').types.isAnyArrayBuffer; diff --git a/lib/child_process.js b/lib/child_process.js index b476887cb4865a..bc86ab3797ad17 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -28,7 +28,7 @@ const { const { isArrayBufferView } = require('internal/util/types'); const debug = util.debuglog('child_process'); const { Buffer } = require('buffer'); -const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap'); +const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); const { ERR_INVALID_ARG_VALUE, ERR_CHILD_PROCESS_IPC_REQUIRED, diff --git a/lib/console.js b/lib/console.js index d72bdf5b27c146..58c9c489987c2b 100644 --- a/lib/console.js +++ b/lib/console.js @@ -29,7 +29,7 @@ const { ERR_INVALID_ARG_VALUE, }, } = require('internal/errors'); -const { previewEntries } = process.binding('util'); +const { previewEntries } = internalBinding('util'); const { Buffer: { isBuffer } } = require('buffer'); const util = require('util'); const { diff --git a/lib/dns.js b/lib/dns.js index 7059ed91ddccc7..326499497b1580 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -21,7 +21,7 @@ 'use strict'; -const cares = process.binding('cares_wrap'); +const cares = internalBinding('cares_wrap'); const { isIP, isIPv4, isLegalPort } = require('internal/net'); const { customPromisifyArgs } = require('internal/util'); const errors = require('internal/errors'); diff --git a/lib/domain.js b/lib/domain.js index beacdc89104411..e8ae3ff1003486 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -34,7 +34,6 @@ const { ERR_UNHANDLED_ERROR } = require('internal/errors').codes; const { createHook } = require('async_hooks'); -const { internalBinding } = require('internal/bootstrap/loaders'); // overwrite process.domain with a getter/setter that will allow for more // effective optimizations diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index 9edb23f8a6bdee..a42f603293c82e 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -4,7 +4,7 @@ const { ERR_ASYNC_TYPE, ERR_INVALID_ASYNC_ID } = require('internal/errors').codes; -const async_wrap = process.binding('async_wrap'); +const async_wrap = internalBinding('async_wrap'); /* async_hook_fields is a Uint32Array wrapping the uint32_t array of * Environment::AsyncHooks::fields_[]. Each index tracks the number of active * hooks for each type. diff --git a/lib/internal/bash_completion.js b/lib/internal/bash_completion.js index 7d2ffbe901d285..cb8eab9ceec855 100644 --- a/lib/internal/bash_completion.js +++ b/lib/internal/bash_completion.js @@ -1,5 +1,4 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { getOptions } = internalBinding('options'); function print(stream) { diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index c04a4207c0b482..5e5a79fd70b100 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -100,7 +100,15 @@ internalBinding = function internalBinding(module) { let mod = bindingObj[module]; if (typeof mod !== 'object') { - mod = bindingObj[module] = getInternalBinding(module); + try { + mod = getInternalBinding(module); + } catch { + // v10.x only: Fall back to `process.binding()`, + // to avoid future merge conflicts when backporting changes that use + // `internalBinding()` to v10.x. + mod = process.binding(module); + } + bindingObj[module] = mod; moduleLoadList.push(`Internal Binding ${module}`); } return mod; @@ -223,7 +231,7 @@ }; NativeModule.wrapper = [ - '(function (exports, require, module, process) {', + '(function (exports, require, module, process, internalBinding) {', '\n});' ]; @@ -294,7 +302,7 @@ const requireFn = this.id.startsWith('internal/deps/') ? NativeModule.requireForDeps : NativeModule.require; - fn(this.exports, requireFn, this, process); + fn(this.exports, requireFn, this, process, internalBinding); if (config.experimentalModules && !NativeModule.isInternal(this.id)) { this.exportKeys = ObjectKeys(this.exports); diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 6b7508905cf836..0a1dc40f8aaf77 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -21,12 +21,12 @@ const dgram = require('dgram'); const util = require('util'); const assert = require('assert'); -const { Process } = process.binding('process_wrap'); -const { WriteWrap } = process.binding('stream_wrap'); -const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap'); -const { TTY } = process.binding('tty_wrap'); -const { TCP } = process.binding('tcp_wrap'); -const { UDP } = process.binding('udp_wrap'); +const { Process } = internalBinding('process_wrap'); +const { WriteWrap } = internalBinding('stream_wrap'); +const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); +const { TCP } = internalBinding('tcp_wrap'); +const { TTY } = internalBinding('tty_wrap'); +const { UDP } = internalBinding('udp_wrap'); const SocketList = require('internal/socket_list'); const { owner_symbol } = require('internal/async_hooks').symbols; const { convertToValidSignal } = require('internal/util'); diff --git a/lib/internal/cluster/round_robin_handle.js b/lib/internal/cluster/round_robin_handle.js index 9c2b448c7709be..6b2bc372545cd9 100644 --- a/lib/internal/cluster/round_robin_handle.js +++ b/lib/internal/cluster/round_robin_handle.js @@ -2,7 +2,7 @@ const assert = require('assert'); const net = require('net'); const { sendHelper } = require('internal/cluster/utils'); -const uv = process.binding('uv'); +const uv = internalBinding('uv'); module.exports = RoundRobinHandle; diff --git a/lib/internal/crypto/keygen.js b/lib/internal/crypto/keygen.js index 63badf22e6963c..6691494675580b 100644 --- a/lib/internal/crypto/keygen.js +++ b/lib/internal/crypto/keygen.js @@ -1,6 +1,6 @@ 'use strict'; -const { AsyncWrap, Providers } = process.binding('async_wrap'); +const { AsyncWrap, Providers } = internalBinding('async_wrap'); const { generateKeyPairRSA, generateKeyPairDSA, diff --git a/lib/internal/crypto/pbkdf2.js b/lib/internal/crypto/pbkdf2.js index 5b2d59eb759115..78c679acd2f1a5 100644 --- a/lib/internal/crypto/pbkdf2.js +++ b/lib/internal/crypto/pbkdf2.js @@ -1,6 +1,6 @@ 'use strict'; -const { AsyncWrap, Providers } = process.binding('async_wrap'); +const { AsyncWrap, Providers } = internalBinding('async_wrap'); const { Buffer } = require('buffer'); const { pbkdf2: _pbkdf2 } = process.binding('crypto'); const { validateUint32 } = require('internal/validators'); diff --git a/lib/internal/crypto/random.js b/lib/internal/crypto/random.js index ea73c85ec5dbf0..c3ef0c448dcaf0 100644 --- a/lib/internal/crypto/random.js +++ b/lib/internal/crypto/random.js @@ -1,6 +1,6 @@ 'use strict'; -const { AsyncWrap, Providers } = process.binding('async_wrap'); +const { AsyncWrap, Providers } = internalBinding('async_wrap'); const { Buffer, kMaxLength } = require('buffer'); const { randomBytes: _randomBytes } = process.binding('crypto'); const { diff --git a/lib/internal/crypto/scrypt.js b/lib/internal/crypto/scrypt.js index c5dfc08cf353ae..c35b77203dfc3d 100644 --- a/lib/internal/crypto/scrypt.js +++ b/lib/internal/crypto/scrypt.js @@ -1,6 +1,6 @@ 'use strict'; -const { AsyncWrap, Providers } = process.binding('async_wrap'); +const { AsyncWrap, Providers } = internalBinding('async_wrap'); const { Buffer } = require('buffer'); const { scrypt: _scrypt } = process.binding('crypto'); const { validateUint32 } = require('internal/validators'); diff --git a/lib/internal/crypto/sig.js b/lib/internal/crypto/sig.js index ebd852402eb328..b21a6a7a10e576 100644 --- a/lib/internal/crypto/sig.js +++ b/lib/internal/crypto/sig.js @@ -5,10 +5,7 @@ const { ERR_INVALID_OPT_VALUE } = require('internal/errors').codes; const { validateString } = require('internal/validators'); -const { - Sign: _Sign, - Verify: _Verify -} = process.binding('crypto'); +const { Sign: _Sign, Verify: _Verify } = internalBinding('crypto'); const { RSA_PSS_SALTLEN_AUTO, RSA_PKCS1_PADDING diff --git a/lib/internal/dgram.js b/lib/internal/dgram.js index 82b65294c21da5..390edda3a94b73 100644 --- a/lib/internal/dgram.js +++ b/lib/internal/dgram.js @@ -1,7 +1,7 @@ 'use strict'; const assert = require('assert'); const { codes } = require('internal/errors'); -const { UDP } = process.binding('udp_wrap'); +const { UDP } = internalBinding('udp_wrap'); const { ERR_INVALID_ARG_TYPE, ERR_SOCKET_BAD_TYPE } = codes; const kStateSymbol = Symbol('state symbol'); let dns; // Lazy load for startup performance. diff --git a/lib/internal/domexception.js b/lib/internal/domexception.js index 586d954dc4912b..3f9d3f36018264 100644 --- a/lib/internal/domexception.js +++ b/lib/internal/domexception.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { registerDOMException } = internalBinding('messaging'); const { ERR_INVALID_THIS } = require('internal/errors').codes; diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index ae874c530ccce9..161ae72a19eaef 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -23,7 +23,6 @@ const { const { isArrayBufferView } = require('internal/util/types'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { isArrayBuffer } = internalBinding('types'); diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 57505150609873..d92b956f81a6e2 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -31,7 +31,6 @@ const { owner_symbol, }, } = require('internal/async_hooks'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { codes: { ERR_HTTP2_ALTSVC_INVALID_ORIGIN, diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index e267c87ea3f6b0..94dc1198ea1060 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -1,6 +1,6 @@ 'use strict'; -const binding = process.binding('http2'); +const binding = internalBinding('http2'); const { ERR_HTTP2_HEADER_SINGLE_VALUE, ERR_HTTP2_INVALID_CONNECTION_HEADERS, diff --git a/lib/internal/modules/esm/create_dynamic_module.js b/lib/internal/modules/esm/create_dynamic_module.js index c01844feb8b654..8e93a08502c3cf 100644 --- a/lib/internal/modules/esm/create_dynamic_module.js +++ b/lib/internal/modules/esm/create_dynamic_module.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { ModuleWrap } = internalBinding('module_wrap'); const debug = require('util').debuglog('esm'); const ArrayJoin = Function.call.bind(Array.prototype.join); diff --git a/lib/internal/modules/esm/default_resolve.js b/lib/internal/modules/esm/default_resolve.js index 875c560cb15079..8f8efcb5360d63 100644 --- a/lib/internal/modules/esm/default_resolve.js +++ b/lib/internal/modules/esm/default_resolve.js @@ -3,7 +3,7 @@ const { URL } = require('url'); const CJSmodule = require('internal/modules/cjs/loader'); const internalFS = require('internal/fs/utils'); -const { NativeModule, internalBinding } = require('internal/bootstrap/loaders'); +const { NativeModule } = require('internal/bootstrap/loaders'); const { extname } = require('path'); const { realpathSync } = require('fs'); const preserveSymlinks = !!process.binding('config').preserveSymlinks; diff --git a/lib/internal/modules/esm/module_job.js b/lib/internal/modules/esm/module_job.js index 9735eae8b50c9c..50aa00a09a03ee 100644 --- a/lib/internal/modules/esm/module_job.js +++ b/lib/internal/modules/esm/module_job.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { ModuleWrap } = internalBinding('module_wrap'); const { SafeSet, SafePromise } = require('internal/safe_globals'); const { decorateErrorStack } = require('internal/util'); diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index aaf35ed461edb9..df3c446cab7ce7 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -1,6 +1,6 @@ 'use strict'; -const { NativeModule, internalBinding } = require('internal/bootstrap/loaders'); +const { NativeModule } = require('internal/bootstrap/loaders'); const { ModuleWrap } = internalBinding('module_wrap'); const { stripShebang, diff --git a/lib/internal/print_help.js b/lib/internal/print_help.js index 065d6524b764cb..8acc9271b19188 100644 --- a/lib/internal/print_help.js +++ b/lib/internal/print_help.js @@ -1,5 +1,4 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { getOptions, types } = internalBinding('options'); const typeLookup = []; diff --git a/lib/internal/process/esm_loader.js b/lib/internal/process/esm_loader.js index 6f3ac729f8143a..23b98c620e64e5 100644 --- a/lib/internal/process/esm_loader.js +++ b/lib/internal/process/esm_loader.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { setImportModuleDynamicallyCallback, setInitializeImportMetaObjectCallback diff --git a/lib/internal/process/promises.js b/lib/internal/process/promises.js index fddf3c8f66eab9..d70deb516025fe 100644 --- a/lib/internal/process/promises.js +++ b/lib/internal/process/promises.js @@ -1,6 +1,6 @@ 'use strict'; -const { safeToString } = process.binding('util'); +const { safeToString } = internalBinding('util'); const maybeUnhandledPromises = new WeakMap(); const pendingUnhandledRejections = []; diff --git a/lib/internal/process/stdio.js b/lib/internal/process/stdio.js index ca09f4ff821a00..826a2a9916e297 100644 --- a/lib/internal/process/stdio.js +++ b/lib/internal/process/stdio.js @@ -41,7 +41,7 @@ function getMainThreadStdio() { function getStdin() { if (stdin) return stdin; - const tty_wrap = process.binding('tty_wrap'); + const tty_wrap = internalBinding('tty_wrap'); const fd = 0; switch (tty_wrap.guessHandleType(fd)) { @@ -157,7 +157,7 @@ function setupProcessStdio({ getStdout, getStdin, getStderr }) { function createWritableStdioStream(fd) { var stream; - const tty_wrap = process.binding('tty_wrap'); + const tty_wrap = internalBinding('tty_wrap'); // Note stream._type is used for test-module-load-list.js diff --git a/lib/internal/stream_base_commons.js b/lib/internal/stream_base_commons.js index 38c7236a680430..8da15983f18997 100644 --- a/lib/internal/stream_base_commons.js +++ b/lib/internal/stream_base_commons.js @@ -1,8 +1,8 @@ 'use strict'; const { Buffer } = require('buffer'); -const { WriteWrap } = process.binding('stream_wrap'); -const { UV_EOF } = process.binding('uv'); +const { WriteWrap } = internalBinding('stream_wrap'); +const { UV_EOF } = internalBinding('uv'); const { errnoException } = require('internal/errors'); const { owner_symbol } = require('internal/async_hooks').symbols; diff --git a/lib/internal/test/binding.js b/lib/internal/test/binding.js index f9f018a78226ce..a47473bf3a6422 100644 --- a/lib/internal/test/binding.js +++ b/lib/internal/test/binding.js @@ -8,7 +8,7 @@ process.emitWarning( // These exports should be scoped as specifically as possible // to avoid exposing APIs because even with that warning and // this file being internal people will still try to abuse it. -const { internalBinding } = require('internal/bootstrap/loaders'); module.exports = { ModuleWrap: internalBinding('module_wrap').ModuleWrap, + internalBinding }; diff --git a/lib/internal/test/heap.js b/lib/internal/test/heap.js index 0a5bf7059713a5..61fe5916fd7584 100644 --- a/lib/internal/test/heap.js +++ b/lib/internal/test/heap.js @@ -5,7 +5,6 @@ process.emitWarning( 'tracked by any versioning system or deprecation process.', 'internal/test/heap'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { createHeapDump, buildEmbedderGraph } = internalBinding('heap_utils'); const assert = require('assert'); diff --git a/lib/internal/trace_events_async_hooks.js b/lib/internal/trace_events_async_hooks.js index 011dc6bbead187..266d8eca4d84da 100644 --- a/lib/internal/trace_events_async_hooks.js +++ b/lib/internal/trace_events_async_hooks.js @@ -1,7 +1,7 @@ 'use strict'; exports.setup = function(traceEvents, traceEventCategory) { - const async_wrap = process.binding('async_wrap'); + const async_wrap = internalBinding('async_wrap'); const async_hooks = require('async_hooks'); // Use small letters such that chrome://tracing groups by the name. diff --git a/lib/internal/util.js b/lib/internal/util.js index 020677d8e6ed55..76c4b93eb854f6 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -6,7 +6,6 @@ const { ERR_UNKNOWN_SIGNAL } = require('internal/errors').codes; const { signals } = process.binding('constants').os; - const { getHiddenValue, setHiddenValue, diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index bddd01b39be63d..205d84f4840886 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -2,8 +2,12 @@ const { compare } = process.binding('buffer'); const { isArrayBufferView } = require('internal/util/types'); -const { internalBinding } = require('internal/bootstrap/loaders'); -const { isDate, isMap, isRegExp, isSet } = internalBinding('types'); +const { + isDate, + isMap, + isRegExp, + isSet +} = internalBinding('types'); const { getOwnNonIndexProperties, propertyFilter: { diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 104944eb19ef3a..5642d7e798dd69 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -1,7 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); - const { getOwnNonIndexProperties, getPromiseDetails, diff --git a/lib/internal/vm/source_text_module.js b/lib/internal/vm/source_text_module.js index af8d3e0e5fe3a3..915289a0591373 100644 --- a/lib/internal/vm/source_text_module.js +++ b/lib/internal/vm/source_text_module.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { URL } = require('internal/url'); const { isContext } = process.binding('contextify'); const { diff --git a/lib/internal/worker.js b/lib/internal/worker.js index 505b83fe56ddf6..88580893cdc015 100644 --- a/lib/internal/worker.js +++ b/lib/internal/worker.js @@ -12,7 +12,6 @@ const { ERR_WORKER_UNSUPPORTED_EXTENSION, } = require('internal/errors').codes; -const { internalBinding } = require('internal/bootstrap/loaders'); const { MessagePort, MessageChannel } = internalBinding('messaging'); const { handle_onclose: handleOnCloseSymbol, diff --git a/lib/internal/wrap_js_stream.js b/lib/internal/wrap_js_stream.js index 4d400233388d83..e6de433676f7d3 100644 --- a/lib/internal/wrap_js_stream.js +++ b/lib/internal/wrap_js_stream.js @@ -3,8 +3,8 @@ const assert = require('assert'); const util = require('util'); const { Socket } = require('net'); -const { JSStream } = process.binding('js_stream'); -const uv = process.binding('uv'); +const { JSStream } = internalBinding('js_stream'); +const uv = internalBinding('uv'); const debug = util.debuglog('stream_wrap'); const { owner_symbol } = require('internal/async_hooks').symbols; const { ERR_STREAM_WRAP } = require('internal/errors').codes; diff --git a/lib/os.js b/lib/os.js index ace39c8e120397..86a24b7c6261eb 100644 --- a/lib/os.js +++ b/lib/os.js @@ -21,7 +21,7 @@ 'use strict'; -const { pushValToArrayMax, safeGetenv } = process.binding('util'); +const { pushValToArrayMax, safeGetenv } = internalBinding('util'); const constants = process.binding('constants').os; const { deprecate } = require('internal/util'); const isWindows = process.platform === 'win32'; diff --git a/lib/string_decoder.js b/lib/string_decoder.js index e5f396cab30d3b..b460da19840c00 100644 --- a/lib/string_decoder.js +++ b/lib/string_decoder.js @@ -22,7 +22,6 @@ 'use strict'; const { Buffer } = require('buffer'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { kIncompleteCharactersStart, kIncompleteCharactersEnd, diff --git a/lib/tls.js b/lib/tls.js index ad752071418fe1..0324f6db877d48 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -29,7 +29,7 @@ const { isUint8Array } = require('internal/util/types'); const net = require('net'); const url = require('url'); -const binding = process.binding('crypto'); +const binding = internalBinding('crypto'); const { Buffer } = require('buffer'); const EventEmitter = require('events'); const DuplexPair = require('internal/streams/duplexpair'); diff --git a/lib/trace_events.js b/lib/trace_events.js index 45015c8a63add0..bf303c28b7dcdc 100644 --- a/lib/trace_events.js +++ b/lib/trace_events.js @@ -16,7 +16,7 @@ const { if (!hasTracing) throw new ERR_TRACE_EVENTS_UNAVAILABLE(); -const { CategorySet, getEnabledCategories } = process.binding('trace_events'); +const { CategorySet, getEnabledCategories } = internalBinding('trace_events'); const { customInspectSymbol } = require('internal/util'); const { format } = require('util'); diff --git a/lib/tty.js b/lib/tty.js index fb0499e6e3101d..62945a78eb1f0f 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -23,7 +23,7 @@ const { inherits, _extend } = require('util'); const net = require('net'); -const { TTY, isTTY } = process.binding('tty_wrap'); +const { TTY, isTTY } = internalBinding('tty_wrap'); const errors = require('internal/errors'); const { ERR_INVALID_FD, ERR_TTY_INIT_FAILED } = errors.codes; const { getColorDepth } = require('internal/tty'); diff --git a/lib/util.js b/lib/util.js index bcea94dc607ab5..fb15b0bfa0549d 100644 --- a/lib/util.js +++ b/lib/util.js @@ -32,7 +32,6 @@ const { validateNumber } = require('internal/validators'); const { TextDecoder, TextEncoder } = require('internal/encoding'); const { isBuffer } = require('buffer').Buffer; -const { internalBinding } = require('internal/bootstrap/loaders'); const types = internalBinding('types'); Object.assign(types, require('internal/util/types')); const { diff --git a/test/parallel/test-bootstrap-modules.js b/test/parallel/test-bootstrap-modules.js index e2e5075f6b2b48..70011637e08af4 100644 --- a/test/parallel/test-bootstrap-modules.js +++ b/test/parallel/test-bootstrap-modules.js @@ -11,4 +11,4 @@ const list = process.moduleLoadList.slice(); const assert = require('assert'); -assert(list.length <= 76, list); +assert(list.length <= 78, list);