@@ -64,18 +64,16 @@ NAN_METHOD(AerospikeClient::New)
64
64
as_config config;
65
65
as_config_init (&config);
66
66
67
- if ( info[0 ]-> IsObject ()) {
68
- Local<Value> v8_log_info = info[ 0 ]-> ToObject ()-> Get ( Nan::New ( " log " ). ToLocalChecked ()) ;
69
- if (v8_log_info-> IsObject ()) {
70
- log_from_jsobject (client-> log , v8_log_info-> ToObject ());
71
- }
67
+ Local<Object> v8Config = info[0 ]. As <Object>();
68
+
69
+ Local<Value> v8LogInfo = v8Config-> Get ( Nan::New ( " log " ). ToLocalChecked ()) ;
70
+ if (v8LogInfo-> IsObject ()) {
71
+ log_from_jsobject (client-> log , v8LogInfo. As <Object>());
72
72
}
73
73
74
- if (info[0 ]->IsObject ()) {
75
- int result = config_from_jsobject (&config, info[0 ]->ToObject (), client->log );
76
- if (result != AS_NODE_PARAM_OK) {
77
- Nan::ThrowError (" Invalid client configuration" );
78
- }
74
+ int result = config_from_jsobject (&config, v8Config, client->log );
75
+ if (result != AS_NODE_PARAM_OK) {
76
+ Nan::ThrowError (" Invalid client configuration" );
79
77
}
80
78
81
79
aerospike_init (client->as , &config);
@@ -159,8 +157,8 @@ NAN_METHOD(AerospikeClient::AddSeedHost)
159
157
TYPE_CHECK_REQ (info[0 ], IsString, " hostname must be a string" );
160
158
TYPE_CHECK_REQ (info[1 ], IsNumber, " port must be a number" );
161
159
162
- Nan::Utf8String hostname (info[0 ]-> ToString ());
163
- uint16_t port = (uint16_t ) info[1 ]-> ToInteger ()-> Value ();
160
+ Nan::Utf8String hostname (info[0 ]. As <String> ());
161
+ uint16_t port = (uint16_t ) Nan::To< uint32_t >( info[1 ]). FromJust ();
164
162
165
163
as_cluster_add_seed (client->as ->cluster , *hostname, NULL , port);
166
164
}
@@ -176,8 +174,8 @@ NAN_METHOD(AerospikeClient::RemoveSeedHost)
176
174
TYPE_CHECK_REQ (info[0 ], IsString, " hostname must be a string" );
177
175
TYPE_CHECK_REQ (info[1 ], IsNumber, " port must be a number" );
178
176
179
- Nan::Utf8String hostname (info[0 ]-> ToString ());
180
- uint16_t port = (uint16_t ) info[1 ]-> ToInteger ()-> Value ();
177
+ Nan::Utf8String hostname (info[0 ]. As <String> ());
178
+ uint16_t port = (uint16_t ) Nan::To< uint32_t >( info[1 ]). FromJust ();
181
179
182
180
as_cluster_remove_seed (client->as ->cluster , *hostname, port);
183
181
}
@@ -186,7 +184,7 @@ NAN_METHOD(AerospikeClient::SetLogLevel)
186
184
{
187
185
AerospikeClient* client = Nan::ObjectWrap::Unwrap<AerospikeClient>(info.Holder ());
188
186
if (info[0 ]->IsObject ()) {
189
- log_from_jsobject (client->log , info[0 ]-> ToObject ());
187
+ log_from_jsobject (client->log , info[0 ]. As <Object> ());
190
188
}
191
189
info.GetReturnValue ().Set (info.Holder ());
192
190
}
0 commit comments