Skip to content

Commit 77c351e

Browse files
committed
Remove v8 deprecation warnings
1 parent 39d0103 commit 77c351e

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/read-poller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ NAN_METHOD(ReadPoller::New) {
7676
}
7777

7878
ReadPoller* obj = new ReadPoller();
79-
obj->fd_ = info[0]->ToInt32()->Int32Value();
79+
obj->fd_ = Nan::To<v8::Int32>(info[0]).ToLocalChecked()->Value();
8080
obj->callback_ = new Nan::Callback(info[1].As<v8::Function>());
8181
obj->Wrap(info.This());
8282
obj->poll_handle_.data = obj;

src/serialport.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,19 @@ v8::Local<v8::Value> getValueFromObject(v8::Local<v8::Object> options, std::stri
8787
}
8888

8989
int getIntFromObject(v8::Local<v8::Object> options, std::string key) {
90-
return getValueFromObject(options, key)->ToInt32()->Int32Value();
90+
return Nan::To<v8::Int32>(getValueFromObject(options, key)).ToLocalChecked()->Value();
9191
}
9292

9393
bool getBoolFromObject(v8::Local<v8::Object> options, std::string key) {
94-
return getValueFromObject(options, key)->ToBoolean()->BooleanValue();
94+
return Nan::To<v8::Boolean>(getValueFromObject(options, key)).ToLocalChecked()->Value();
9595
}
9696

9797
v8::Local<v8::String> getStringFromObj(v8::Local<v8::Object> options, std::string key) {
98-
return getValueFromObject(options, key)->ToString();
98+
return Nan::To<v8::String>(getValueFromObject(options, key)).ToLocalChecked();
9999
}
100100

101101
double getDoubleFromObject(v8::Local<v8::Object> options, std::string key) {
102-
return getValueFromObject(options, key)->ToNumber()->NumberValue();
102+
return Nan::To<double>(getValueFromObject(options, key)).FromMaybe(0);
103103
}
104104

105105
NAN_METHOD(Open) {
@@ -162,7 +162,7 @@ void EIO_AfterOpen(uv_work_t* req) {
162162
argv[0] = Nan::Null();
163163
argv[1] = Nan::New<v8::Int32>(data->result);
164164

165-
int fd = argv[1]->ToInt32()->Int32Value();
165+
int fd = Nan::To<v8::Int32>(argv[1]).ToLocalChecked()->Value();
166166
newQForFD(fd);
167167
}
168168

@@ -177,7 +177,7 @@ NAN_METHOD(Update) {
177177
Nan::ThrowTypeError("First argument must be an int");
178178
return;
179179
}
180-
int fd = info[0]->ToInt32()->Int32Value();
180+
int fd = Nan::To<v8::Int32>(info[0]).ToLocalChecked()->Value();
181181

182182
// options
183183
if (!info[1]->IsObject()) {
@@ -201,7 +201,7 @@ NAN_METHOD(Update) {
201201
memset(baton, 0, sizeof(ConnectionOptionsBaton));
202202

203203
baton->fd = fd;
204-
baton->baudRate = Nan::Get(options, Nan::New<v8::String>("baudRate").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value();
204+
baton->baudRate = getIntFromObject(options, "baudRate");
205205
baton->callback.Reset(info[2].As<v8::Function>());
206206

207207
uv_work_t* req = new uv_work_t();
@@ -234,7 +234,7 @@ NAN_METHOD(Write) {
234234
Nan::ThrowTypeError("First argument must be an int");
235235
return;
236236
}
237-
int fd = info[0]->ToInt32()->Int32Value();
237+
int fd = Nan::To<v8::Int32>(info[0]).ToLocalChecked()->Value();
238238

239239
// buffer
240240
if (!info[1]->IsObject() || !node::Buffer::HasInstance(info[1])) {
@@ -351,7 +351,7 @@ NAN_METHOD(Close) {
351351

352352
VoidBaton* baton = new VoidBaton();
353353
memset(baton, 0, sizeof(VoidBaton));
354-
baton->fd = info[0]->ToInt32()->Int32Value();
354+
baton->fd = Nan::To<v8::Int32>(info[0]).ToLocalChecked()->Value();
355355
baton->callback.Reset(info[1].As<v8::Function>());
356356

357357
uv_work_t* req = new uv_work_t();
@@ -457,7 +457,7 @@ NAN_METHOD(Flush) {
457457
Nan::ThrowTypeError("First argument must be an int");
458458
return;
459459
}
460-
int fd = info[0]->ToInt32()->Int32Value();
460+
int fd = Nan::To<v8::Int32>(info[0]).ToLocalChecked()->Value();
461461

462462
// callback
463463
if (!info[1]->IsFunction()) {
@@ -501,7 +501,7 @@ NAN_METHOD(Set) {
501501
Nan::ThrowTypeError("First argument must be an int");
502502
return;
503503
}
504-
int fd = info[0]->ToInt32()->Int32Value();
504+
int fd = Nan::To<v8::Int32>(info[0]).ToLocalChecked()->Value();
505505

506506
// options
507507
if (!info[1]->IsObject()) {
@@ -556,7 +556,7 @@ NAN_METHOD(Get) {
556556
Nan::ThrowTypeError("First argument must be an int");
557557
return;
558558
}
559-
int fd = info[0]->ToInt32()->Int32Value();
559+
int fd = Nan::To<v8::Int32>(info[0]).ToLocalChecked()->Value();
560560

561561
// callback
562562
if (!info[1]->IsFunction()) {
@@ -608,7 +608,7 @@ NAN_METHOD(Drain) {
608608
Nan::ThrowTypeError("First argument must be an int");
609609
return;
610610
}
611-
int fd = info[0]->ToInt32()->Int32Value();
611+
int fd = Nan::To<v8::Int32>(info[0]).ToLocalChecked()->Value();
612612

613613
// callback
614614
if (!info[1]->IsFunction()) {

0 commit comments

Comments
 (0)