process: wrap process.binding for selective fallthrough
Selectively fallthrough `process.binding()` to `internalBinding()` Refs: https://github.com/nodejs/node/pull/22163 PR-URL: https://github.com/nodejs/node/pull/22269 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
a091fbeb7f
commit
0257fd7ce9
@ -318,6 +318,21 @@
|
|||||||
for (var i = 0; i < arguments.length; i++)
|
for (var i = 0; i < arguments.length; i++)
|
||||||
this.push(arguments[i]);
|
this.push(arguments[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated specific process.binding() modules, but not all, allow
|
||||||
|
// selective fallback to internalBinding for the deprecated ones.
|
||||||
|
const { SafeSet } = NativeModule.require('internal/safe_globals');
|
||||||
|
const processBinding = process.binding;
|
||||||
|
// internalBindingWhitelist contains the name of internalBinding modules
|
||||||
|
// that are whitelisted for access via process.binding()... this is used
|
||||||
|
// to provide a transition path for modules that are being moved over to
|
||||||
|
// internalBinding.
|
||||||
|
const internalBindingWhitelist = new SafeSet(['uv']);
|
||||||
|
process.binding = function binding(name) {
|
||||||
|
return internalBindingWhitelist.has(name) ?
|
||||||
|
internalBinding(name) :
|
||||||
|
processBinding(name);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupGlobalVariables() {
|
function setupGlobalVariables() {
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
// Flags: --no-warnings
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
// Assert that whitelisted internalBinding modules are accessible via
|
||||||
|
// process.binding().
|
||||||
|
assert(process.binding('uv'));
|
Loading…
x
Reference in New Issue
Block a user