GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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.

Sign up for GitHub

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

Merged
cjihrig merged 2 commits into nodejs:master from cjihrig:util-binding
Sep 6, 2018

Uh oh!

There was an error while loading. Please reload this page.

Merged

util: make util binding internal #22675

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
7e4b0a4
util: make util binding internal
cjihrig Sep 3, 2018
2bf4697
repl: remove duplicate util binding
cjihrig Sep 3, 2018
File filter
Filter by extension

Clear filters
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
Diff view

There are no files selected for viewing

3 changes: 2 additions & 1 deletion 3 benchmark/util/type-check.js
Show comments
View file
Open in desktop
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
3 changes: 2 additions & 1 deletion 3 lib/console.js
Show comments
View file
Open in desktop
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
3 changes: 2 additions & 1 deletion 3 lib/internal/bootstrap/node.js
Show comments
View file
Open in desktop
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
4 changes: 2 additions & 2 deletions 4 lib/internal/modules/cjs/loader.js
Show comments
View file
Open in desktop
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
3 changes: 2 additions & 1 deletion 3 lib/internal/process/promises.js
Show comments
View file
Open in desktop
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
5 changes: 2 additions & 3 deletions 5 lib/internal/util.js
Show comments
View file
Open in desktop
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
2 changes: 1 addition & 1 deletion 2 lib/internal/util/comparisons.js
Show comments
View file
Open in desktop
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
Show comments
View file
Open in desktop
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
12 changes: 7 additions & 5 deletions 12 lib/repl.js
Show comments
View file
Open in desktop
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
3 changes: 2 additions & 1 deletion 3 lib/stream.js
Show comments
View file
Open in desktop
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 addaleax Oct 14, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

All reactions
}
} catch (e) {
}
Expand Down
4 changes: 2 additions & 2 deletions 4 lib/util.js
Show comments
View file
Open in desktop
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
2 changes: 1 addition & 1 deletion 2 src/node_util.cc
Show comments
View file
Open in desktop
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)
2 changes: 1 addition & 1 deletion 2 test/parallel/test-internal-module-wrap.js
Show comments
View file
Open in desktop
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
3 changes: 2 additions & 1 deletion 3 test/parallel/test-internal-util-decorate-error-stack.js
Show comments
View file
Open in desktop
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
4 changes: 3 additions & 1 deletion 4 test/parallel/test-util-inspect-proxy.js
Show comments
View file
Open in desktop
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
4 changes: 3 additions & 1 deletion 4 test/parallel/test-util-inspect.js
Show comments
View file
Open in desktop
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
3 changes: 2 additions & 1 deletion 3 test/parallel/test-util-internal.js
Show comments
View file
Open in desktop
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
4 changes: 3 additions & 1 deletion 4 test/parallel/test-util-sigint-watchdog.js
Show comments
View file
Open in desktop
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.