@@ -64,13 +64,13 @@ static void GetPromiseDetails(const FunctionCallbackInfo<Value>& args) {
64
64
auto isolate = args.GetIsolate ();
65
65
66
66
Local<Promise> promise = args[0 ].As <Promise>();
67
- Local<Array> ret = Array::New (isolate, 2 );
68
67
69
68
int state = promise->State ();
70
- ret->Set (env->context (), 0 , Integer::New (isolate, state)).FromJust ();
69
+ Local<Value> values[2 ] = { Integer::New (isolate, state) };
70
+ size_t number_of_values = 1 ;
71
71
if (state != Promise::PromiseState::kPending )
72
- ret-> Set (env-> context (), 1 , promise->Result ()). FromJust ();
73
-
72
+ values[number_of_values++] = promise->Result ();
73
+ Local<Array> ret = Array::New (isolate, values, number_of_values);
74
74
args.GetReturnValue ().Set (ret);
75
75
}
76
76
@@ -82,11 +82,13 @@ static void GetProxyDetails(const FunctionCallbackInfo<Value>& args) {
82
82
83
83
Local<Proxy> proxy = args[0 ].As <Proxy>();
84
84
85
- Local<Array> ret = Array::New (args.GetIsolate (), 2 );
86
- ret->Set (env->context (), 0 , proxy->GetTarget ()).FromJust ();
87
- ret->Set (env->context (), 1 , proxy->GetHandler ()).FromJust ();
85
+ Local<Value> ret[] = {
86
+ proxy->GetTarget (),
87
+ proxy->GetHandler ()
88
+ };
88
89
89
- args.GetReturnValue ().Set (ret);
90
+ args.GetReturnValue ().Set (
91
+ Array::New (args.GetIsolate (), ret, arraysize (ret)));
90
92
}
91
93
92
94
static void PreviewEntries (const FunctionCallbackInfo<Value>& args) {
@@ -101,11 +103,13 @@ static void PreviewEntries(const FunctionCallbackInfo<Value>& args) {
101
103
// Fast path for WeakMap, WeakSet and Set iterators.
102
104
if (args.Length () == 1 )
103
105
return args.GetReturnValue ().Set (entries);
104
- Local<Array> ret = Array::New (env->isolate (), 2 );
105
- ret->Set (env->context (), 0 , entries).FromJust ();
106
- ret->Set (env->context (), 1 , Boolean::New (env->isolate (), is_key_value))
107
- .FromJust ();
108
- return args.GetReturnValue ().Set (ret);
106
+
107
+ Local<Value> ret[] = {
108
+ entries,
109
+ Boolean::New (env->isolate (), is_key_value)
110
+ };
111
+ return args.GetReturnValue ().Set (
112
+ Array::New (env->isolate (), ret, arraysize (ret)));
109
113
}
110
114
111
115
// Side effect-free stringification that will never throw exceptions.
0 commit comments