Skip to content

Commit

Permalink
lib: rename internalBinding to _internalBinding
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Apr 2, 2023
1 parent b45105b commit 152d00a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/internal/bootstrap/loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,12 @@ const schemelessBlockList = new SafeSet([
}

// Set up internalBinding() in the closure.
let internalBinding;
// Do not use `internalBinding` variable name due to the breakage of TypeScript autocompletion.
let _internalBinding;
{
const bindingObj = { __proto__: null };
// eslint-disable-next-line no-global-assign
internalBinding = function internalBinding(module) {
_internalBinding = function internalBinding(module) {
let mod = bindingObj[module];
if (typeof mod !== 'object') {
mod = bindingObj[module] = getInternalBinding(module);
Expand All @@ -180,7 +181,7 @@ const {
builtinIds,
compileFunction,
setInternalLoaders,
} = internalBinding('builtins');
} = _internalBinding('builtins');

const getOwn = (target, property, receiver) => {
return ObjectPrototypeHasOwnProperty(target, property) ?
Expand Down Expand Up @@ -278,7 +279,7 @@ class BuiltinModule {

getESMFacade() {
if (this.module) return this.module;
const { ModuleWrap } = internalBinding('module_wrap');
const { ModuleWrap } = _internalBinding('module_wrap');
// TODO(aduh95): move this to C++, alongside the initialization of the class.
ObjectSetPrototypeOf(ModuleWrap.prototype, null);
const url = `node:${this.id}`;
Expand Down Expand Up @@ -328,7 +329,7 @@ class BuiltinModule {
const fn = compileFunction(id);
// Arguments must match the parameters specified in
// BuiltinLoader::LookupAndCompile().
fn(this.exports, requireFn, this, process, internalBinding, primordials);
fn(this.exports, requireFn, this, process, _internalBinding, primordials);

this.loaded = true;
} finally {
Expand All @@ -345,7 +346,7 @@ class BuiltinModule {
// Think of this as module.exports in this file even though it is not
// written in CommonJS style.
const loaderExports = {
internalBinding,
internalBinding: _internalBinding,
BuiltinModule,
require: requireBuiltin,
};
Expand All @@ -372,4 +373,4 @@ function requireWithFallbackInDeps(request) {
}

// Store the internal loaders in C++.
setInternalLoaders(internalBinding, requireBuiltin);
setInternalLoaders(_internalBinding, requireBuiltin);

0 comments on commit 152d00a

Please sign in to comment.