@@ -23,6 +23,7 @@ using v8::Isolate;
2323using v8::KeyCollectionMode;
2424using v8::Local;
2525using v8::Object;
26+ using v8::ObjectTemplate;
2627using v8::ONLY_CONFIGURABLE;
2728using v8::ONLY_ENUMERABLE;
2829using v8::ONLY_WRITABLE;
@@ -379,27 +380,45 @@ void Initialize(Local<Object> target,
379380 .Check ();
380381 }
381382
382- #define V (name ) \
383- target->Set (context, \
384- FIXED_ONE_BYTE_STRING (env->isolate (), #name), \
385- Integer::New (env->isolate (), Promise::PromiseState::name)) \
386- .FromJust ()
387- V (kPending );
388- V (kFulfilled );
389- V (kRejected );
383+ {
384+ Local<ObjectTemplate> tmpl = ObjectTemplate::New (isolate);
385+ #define V (name ) \
386+ tmpl->Set (FIXED_ONE_BYTE_STRING (isolate, #name), \
387+ Integer::New (isolate, Promise::PromiseState::name));
388+
389+ V (kPending );
390+ V (kFulfilled );
391+ V (kRejected );
392+ #undef V
393+
394+ #define V (name ) \
395+ tmpl->Set (FIXED_ONE_BYTE_STRING (isolate, #name), \
396+ Integer::New (isolate, Environment::ExitInfoField::name));
397+
398+ V (kExiting );
399+ V (kExitCode );
400+ V (kHasExitCode );
390401#undef V
391402
392403#define V (name ) \
393- target \
394- ->Set (context, \
395- FIXED_ONE_BYTE_STRING (env->isolate (), #name), \
396- Integer::New (env->isolate (), Environment::ExitInfoField::name)) \
397- .FromJust ()
398- V (kExiting );
399- V (kExitCode );
400- V (kHasExitCode );
404+ tmpl->Set (FIXED_ONE_BYTE_STRING (isolate, #name), \
405+ Integer::New (isolate, PropertyFilter::name));
406+
407+ V (ALL_PROPERTIES);
408+ V (ONLY_WRITABLE);
409+ V (ONLY_ENUMERABLE);
410+ V (ONLY_CONFIGURABLE);
411+ V (SKIP_STRINGS);
412+ V (SKIP_SYMBOLS);
401413#undef V
402414
415+ target
416+ ->Set (context,
417+ env->constants_string (),
418+ tmpl->NewInstance (context).ToLocalChecked ())
419+ .Check ();
420+ }
421+
403422 SetMethodNoSideEffect (
404423 context, target, " getPromiseDetails" , GetPromiseDetails);
405424 SetMethodNoSideEffect (context, target, " getProxyDetails" , GetProxyDetails);
@@ -413,16 +432,6 @@ void Initialize(Local<Object> target,
413432
414433 SetMethod (
415434 context, target, " arrayBufferViewHasBuffer" , ArrayBufferViewHasBuffer);
416- Local<Object> constants = Object::New (env->isolate ());
417- NODE_DEFINE_CONSTANT (constants, ALL_PROPERTIES);
418- NODE_DEFINE_CONSTANT (constants, ONLY_WRITABLE);
419- NODE_DEFINE_CONSTANT (constants, ONLY_ENUMERABLE);
420- NODE_DEFINE_CONSTANT (constants, ONLY_CONFIGURABLE);
421- NODE_DEFINE_CONSTANT (constants, SKIP_STRINGS);
422- NODE_DEFINE_CONSTANT (constants, SKIP_SYMBOLS);
423- target->Set (context,
424- FIXED_ONE_BYTE_STRING (env->isolate (), " propertyFilter" ),
425- constants).Check ();
426435
427436 Local<String> should_abort_on_uncaught_toggle =
428437 FIXED_ONE_BYTE_STRING (env->isolate (), " shouldAbortOnUncaughtToggle" );
0 commit comments