GeezerVison is showing github.com — util: make util binding internal by cjihrig · Pull Request #22675 · nodejs/node
util: make util binding internal
#22675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.cc
(1)
.js
(17)
All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -38,7 +38,8 @@ function main({ type, argument, version, n }) {
// For testing, if supplied with an empty type, default to ArrayBufferView.
type = type || 'ArrayBufferView';
const util = process.binding('util');
const { internalBinding } = require('internal/test/binding');
const util = internalBinding('util');
const types = require('internal/util/types');
const func = { native: util, js: types }[version][`is${type}`];
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -29,7 +29,8 @@ const {
ERR_INVALID_ARG_VALUE,
},
} = require('internal/errors');
const { previewEntries } = process.binding('util');
const { internalBinding } = require('internal/bootstrap/loaders');
const { previewEntries } = internalBinding('util');
const { Buffer: { isBuffer } } = require('buffer');
const util = require('util');
const {
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -176,7 +176,7 @@
// TODO(addaleax): Turn into a full runtime deprecation.
const { pendingDeprecation } = process.binding('config');
const { deprecate } = NativeModule.require('internal/util');
const utilBinding = process.binding ('util');
const utilBinding = internalBinding ('util');
const types = internalBinding('types');
for (const name of [
'isArrayBuffer', 'isArrayBufferView', 'isAsyncFunction',
Expand Down
Expand Up
@@ -374,6 +374,7 @@
'contextify',
'tcp_wrap',
'tls_wrap',
'util',
'async_wrap']);
process.binding = function binding(name) {
return internalBindingWhitelist.has(name) ?
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -21,7 +21,7 @@
'use strict';
const { NativeModule } = require('internal/bootstrap/loaders');
const { internalBinding, NativeModule } = require('internal/bootstrap/loaders');
const util = require('util');
const vm = require('vm');
const assert = require('assert').ok;
Expand All
@@ -32,7 +32,7 @@ const {
internalModuleReadJSON,
internalModuleStat
} = process.binding('fs');
const { safeGetenv } = process.binding ('util');
const { safeGetenv } = internalBinding ('util');
const {
makeRequireFunction,
requireDepth,
Expand Down
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
'use strict';
const { safeToString } = process.binding('util');
const { internalBinding } = require('internal/bootstrap/loaders');
const { safeToString } = internalBinding('util');
const maybeUnhandledPromises = new WeakMap();
const pendingUnhandledRejections = [];
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -6,15 +6,14 @@ const {
ERR_UNKNOWN_SIGNAL
} = require('internal/errors').codes;
const { signals } = process.binding('constants').os;
const { internalBinding } = require('internal/bootstrap/loaders');
const {
getHiddenValue,
setHiddenValue,
arrow_message_private_symbol: kArrowMessagePrivateSymbolIndex,
decorated_private_symbol: kDecoratedPrivateSymbolIndex
} = process.binding ('util');
} = internalBinding ('util');
const { internalBinding } = require('internal/bootstrap/loaders');
const { errmap } = internalBinding('uv');
const noCrypto = !process.versions.openssl;
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -15,7 +15,7 @@ const {
propertyFilter: {
ONLY_ENUMERABLE
}
} = process.binding ('util');
} = internalBinding ('util');
const ReflectApply = Reflect.apply;
Expand Down
3 changes: 2 additions & 1 deletion
3
lib/os.js
Original file line number
Diff line number
Diff line change
Expand Up
@@ -21,7 +21,8 @@
'use strict';
const { pushValToArrayMax, safeGetenv } = process.binding('util');
const { internalBinding } = require('internal/bootstrap/loaders');
const { pushValToArrayMax, safeGetenv } = internalBinding('util');
const constants = process.binding('constants').os;
const { deprecate } = require('internal/util');
const isWindows = process.platform === 'win32';
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -53,7 +53,7 @@ const {
} = require('internal/deps/acorn/dist/acorn');
const internalUtil = require('internal/util');
const util = require('util');
const utilBinding = process.binding('util ');
const { internalBinding } = require('internal/bootstrap/loaders ');
const { inherits } = util;
const Stream = require('stream');
const vm = require('vm');
Expand All
@@ -78,8 +78,10 @@ const {
propertyFilter: {
ALL_PROPERTIES,
SKIP_SYMBOLS
}
} = process.binding('util');
},
startSigintWatchdog,
stopSigintWatchdog
} = internalBinding('util');
// Lazy-loaded.
let processTopLevelAwait;
Expand Down
Expand Up
@@ -313,7 +315,7 @@ function REPLServer(prompt,
if (self.breakEvalOnSigint) {
// Start the SIGINT watchdog before entering raw mode so that a very
// quick Ctrl+C doesn't lead to aborting the process completely.
if (!utilBinding. startSigintWatchdog())
if (!startSigintWatchdog())
throw new ERR_CANNOT_WATCH_SIGINT();
previouslyInRawMode = self._setRawMode(false);
}
Expand All
@@ -337,7 +339,7 @@ function REPLServer(prompt,
// Returns true if there were pending SIGINTs *after* the script
// has terminated without being interrupted itself.
if (utilBinding. stopSigintWatchdog()) {
if (stopSigintWatchdog()) {
self.emit('SIGINT');
}
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -49,7 +49,8 @@ try {
} else {
// This throws for Node < 4.2.0 because there's no util binding and
// returns undefined for Node < 7.4.0.
Stream._isUint8Array = process.binding('util').isUint8Array;
const { internalBinding } = require('internal/bootstrap/loaders');
Stream._isUint8Array = internalBinding('util').isUint8Array;
Comment thread
addaleax
Oct 14, 2018
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
I think we want to revert this change, since it is only left in the file for compatibility with prior Node.js versions in readable-stream.
/cc @nodejs/streams
edit: #23662
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
}
} catch (e) {
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -31,15 +31,15 @@ const { validateNumber } = require('internal/validators');
const { TextDecoder, TextEncoder } = require('internal/encoding');
const { isBuffer } = require('buffer').Buffer;
const { internalBinding } = require('internal/bootstrap/loaders');
const {
getPromiseDetails,
getProxyDetails,
kPending,
kRejected,
previewEntries
} = process.binding ('util');
} = internalBinding ('util');
const { internalBinding } = require('internal/bootstrap/loaders');
const types = internalBinding('types');
Object.assign(types, require('internal/util/types'));
const {
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -234,4 +234,4 @@ void Initialize(Local<Object> target,
} // namespace util
} // namespace node
NODE_BUILTIN_MODULE_CONTEXT_AWARE (util, node::util::Initialize)
NODE_MODULE_CONTEXT_AWARE_INTERNAL (util, node::util::Initialize)
Original file line number
Diff line number
Diff line change
Expand Up
@@ -7,7 +7,7 @@ const assert = require('assert');
const { internalBinding } = require('internal/test/binding');
const { ModuleWrap } = internalBinding('module_wrap');
const { getPromiseDetails, isPromise } = process.binding ('util');
const { getPromiseDetails, isPromise } = internalBinding ('util');
const setTimeoutAsync = require('util').promisify(setTimeout);
const foo = new ModuleWrap('export * from "bar"; 6;', 'foo');
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -4,7 +4,8 @@ require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const internalUtil = require('internal/util');
const binding = process.binding('util');
const { internalBinding } = require('internal/test/binding');
const binding = internalBinding('util');
const spawnSync = require('child_process').spawnSync;
const kArrowMessagePrivateSymbolIndex = binding.arrow_message_private_symbol;
Expand Down
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,11 @@
// Flags: --expose-internals
'use strict';
require('../common');
const assert = require('assert');
const util = require('util');
const processUtil = process.binding('util');
const { internalBinding } = require('internal/test/binding');
const processUtil = internalBinding('util');
const opts = { showProxy: true };
const target = {};
Expand Down
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
// Flags: --expose-internals
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
Expand All
@@ -22,10 +23,11 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const { internalBinding } = require('internal/test/binding');
const JSStream = process.binding('js_stream').JSStream;
const util = require('util');
const vm = require('vm');
const { previewEntries } = process.binding ('util');
const { previewEntries } = internalBinding ('util');
const { inspect } = util;
assert.strictEqual(util.inspect(1), '1');
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -4,13 +4,14 @@
require('../common');
const assert = require('assert');
const fixtures = require('../common/fixtures');
const { internalBinding } = require('internal/test/binding');
const {
getHiddenValue,
setHiddenValue,
arrow_message_private_symbol: kArrowMessagePrivateSymbolIndex,
safeGetenv
} = process.binding ('util');
} = internalBinding ('util');
for (const oneEnv in process.env) {
assert.strictEqual(
Expand Down
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
if (common.isWindows) {
Expand All
@@ -6,7 +7,8 @@ if (common.isWindows) {
}
const assert = require('assert');
const binding = process.binding('util');
const { internalBinding } = require('internal/test/binding');
const binding = internalBinding('util');
[(next) => {
// Test with no signal observed.
Expand Down
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.