diff --git a/lib/buffer.js b/lib/buffer.js index 898bc5032e5f8d..08aa52b3883ea1 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -67,11 +67,11 @@ const { kStringMaxLength } = internalBinding('buffer'); const { - getOwnNonIndexProperties, - propertyFilter: { + constants: { ALL_PROPERTIES, - ONLY_ENUMERABLE + ONLY_ENUMERABLE, }, + getOwnNonIndexProperties, } = internalBinding('util'); const { customInspectSymbol, diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index c126bd6346dae7..e41fcf2daf92a0 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -46,11 +46,11 @@ const { isFloat64Array, } = types; const { - getOwnNonIndexProperties, - propertyFilter: { + constants: { ONLY_ENUMERABLE, - SKIP_SYMBOLS - } + SKIP_SYMBOLS, + }, + getOwnNonIndexProperties, } = internalBinding('util'); const kStrict = true; diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 7f9d33a7f03497..6174d62bb11643 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -97,18 +97,18 @@ const { } = primordials; const { + constants: { + ALL_PROPERTIES, + ONLY_ENUMERABLE, + kPending, + kRejected, + }, getOwnNonIndexProperties, getPromiseDetails, getProxyDetails, - kPending, - kRejected, previewEntries, getConstructorName: internalGetConstructorName, getExternalValue, - propertyFilter: { - ALL_PROPERTIES, - ONLY_ENUMERABLE - } } = internalBinding('util'); const { diff --git a/lib/internal/webstreams/util.js b/lib/internal/webstreams/util.js index 1cf2d3a1874b10..5e0a75d2b30265 100644 --- a/lib/internal/webstreams/util.js +++ b/lib/internal/webstreams/util.js @@ -40,8 +40,10 @@ const { } = require('util'); const { + constants: { + kPending, + }, getPromiseDetails, - kPending, } = internalBinding('util'); const assert = require('internal/assert'); diff --git a/lib/repl.js b/lib/repl.js index f2996d660d8d6f..124d4781498cc4 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -166,11 +166,11 @@ const { setupReverseSearch, } = require('internal/repl/utils'); const { - getOwnNonIndexProperties, - propertyFilter: { + constants: { ALL_PROPERTIES, - SKIP_SYMBOLS - } + SKIP_SYMBOLS, + }, + getOwnNonIndexProperties, } = internalBinding('util'); const { startSigintWatchdog, diff --git a/src/node_util.cc b/src/node_util.cc index 4d6c757c2fe422..ecb591698a4e82 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -387,16 +387,38 @@ void Initialize(Local target, .Check(); } -#define V(name) \ - target->Set(context, \ - FIXED_ONE_BYTE_STRING(env->isolate(), #name), \ - Integer::New(env->isolate(), Promise::PromiseState::name)) \ - .FromJust() - V(kPending); - V(kFulfilled); - V(kRejected); + { + Local constants = Object::New(isolate); +#define V(name) \ + constants \ + ->Set(context, \ + FIXED_ONE_BYTE_STRING(isolate, #name), \ + Integer::New(isolate, Promise::PromiseState::name)) \ + .Check(); + + V(kPending); + V(kFulfilled); + V(kRejected); +#undef V + +#define V(name) \ + constants \ + ->Set(context, \ + FIXED_ONE_BYTE_STRING(isolate, #name), \ + Integer::New(isolate, PropertyFilter::name)) \ + .Check(); + + V(ALL_PROPERTIES); + V(ONLY_WRITABLE); + V(ONLY_ENUMERABLE); + V(ONLY_CONFIGURABLE); + V(SKIP_STRINGS); + V(SKIP_SYMBOLS); #undef V + target->Set(context, env->constants_string(), constants).Check(); + } + SetMethodNoSideEffect( context, target, "getPromiseDetails", GetPromiseDetails); SetMethodNoSideEffect(context, target, "getProxyDetails", GetProxyDetails); @@ -410,16 +432,6 @@ void Initialize(Local target, SetMethod( context, target, "arrayBufferViewHasBuffer", ArrayBufferViewHasBuffer); - Local constants = Object::New(env->isolate()); - NODE_DEFINE_CONSTANT(constants, ALL_PROPERTIES); - NODE_DEFINE_CONSTANT(constants, ONLY_WRITABLE); - NODE_DEFINE_CONSTANT(constants, ONLY_ENUMERABLE); - NODE_DEFINE_CONSTANT(constants, ONLY_CONFIGURABLE); - NODE_DEFINE_CONSTANT(constants, SKIP_STRINGS); - NODE_DEFINE_CONSTANT(constants, SKIP_SYMBOLS); - target->Set(context, - FIXED_ONE_BYTE_STRING(env->isolate(), "propertyFilter"), - constants).Check(); Local should_abort_on_uncaught_toggle = FIXED_ONE_BYTE_STRING(env->isolate(), "shouldAbortOnUncaughtToggle");