Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Squash] address feedback
  • Loading branch information
jasnell committed Aug 13, 2018
commit 7e4af610e5d98302e28ef2560c8386718bd4c617
21 changes: 9 additions & 12 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,20 +321,17 @@

// 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;
const internalBindingWhitelist = new Set(['uv']);
const internalBindingWarned = new Set();
// 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) {
if (internalBindingWhitelist.has(name)) {
if (!internalBindingWarned.has(name)) {
process.emitWarning(
`Use of process.binding('${name}') is deprecated.`,
'DeprecationWarning', 'DEP0111');
internalBindingWarned.add(name);
}
return internalBinding(name);
}
return processBinding(name);
return internalBindingWhitelist.has(name) ?
internalBinding(name) :
processBinding(name);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
const common = require('../common');
const assert = require('assert');

common.expectWarning(
'DeprecationWarning',
'Use of process.binding(\'uv\') is deprecated.',
'DEP0111'
);

// Assert that whitelisted internalBinding modules are accessible via
// process.binding().
assert(process.binding('uv'));