@@ -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;
@@ -364,7 +365,7 @@ void Initialize(Local<Object> target,
364365  Isolate* isolate = env->isolate ();
365366
366367  {
367-     Local<v8:: ObjectTemplate> tmpl = v8:: ObjectTemplate::New (isolate);
368+     Local<ObjectTemplate> tmpl = ObjectTemplate::New (isolate);
368369#define  V (PropertyName, _ )                                                     \
369370  tmpl->Set (FIXED_ONE_BYTE_STRING (env->isolate (), #PropertyName),              \
370371            env->PropertyName ());
@@ -379,27 +380,50 @@ 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<Object> constants = Object::New (isolate);
385+ #define  V (name )                                                                \
386+   constants                                                                    \
387+       ->Set (context,                                                           \
388+             FIXED_ONE_BYTE_STRING (isolate, #name),                             \
389+             Integer::New (isolate, Promise::PromiseState::name))                \
390+       .Check ();
391+ 
392+     V (kPending );
393+     V (kFulfilled );
394+     V (kRejected );
390395#undef  V
391396
392397#define  V (name )                                                                \
393-   target                                                                        \
398+   constants                                                                     \
394399      ->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 );
400+             FIXED_ONE_BYTE_STRING (isolate, #name),                             \
401+             Integer::New (isolate, Environment::ExitInfoField::name))           \
402+       .Check ();
403+ 
404+     V (kExiting );
405+     V (kExitCode );
406+     V (kHasExitCode );
401407#undef  V
402408
409+ #define  V (name )                                                                \
410+   constants                                                                    \
411+       ->Set (context,                                                           \
412+             FIXED_ONE_BYTE_STRING (isolate, #name),                             \
413+             Integer::New (isolate, PropertyFilter::name))                       \
414+       .Check ();
415+ 
416+     V (ALL_PROPERTIES);
417+     V (ONLY_WRITABLE);
418+     V (ONLY_ENUMERABLE);
419+     V (ONLY_CONFIGURABLE);
420+     V (SKIP_STRINGS);
421+     V (SKIP_SYMBOLS);
422+ #undef  V
423+ 
424+     target->Set (context, env->constants_string (), constants).Check ();
425+   }
426+ 
403427  SetMethodNoSideEffect (
404428      context, target, " getPromiseDetails"  , GetPromiseDetails);
405429  SetMethodNoSideEffect (context, target, " getProxyDetails"  , GetProxyDetails);
@@ -413,16 +437,6 @@ void Initialize(Local<Object> target,
413437
414438  SetMethod (
415439      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 ();
426440
427441  Local<String> should_abort_on_uncaught_toggle =
428442      FIXED_ONE_BYTE_STRING (env->isolate (), " shouldAbortOnUncaughtToggle"  );
0 commit comments