diff --git a/packages/serialport-util/packages/node-serialport/src/read-poller.cpp b/packages/serialport-util/packages/node-serialport/src/read-poller.cpp index b3c2e3dc6e..fb0de0dd2d 100644 --- a/packages/serialport-util/packages/node-serialport/src/read-poller.cpp +++ b/packages/serialport-util/packages/node-serialport/src/read-poller.cpp @@ -76,7 +76,7 @@ NAN_METHOD(ReadPoller::New) { } ReadPoller* obj = new ReadPoller(); - obj->fd_ = info[0]->ToInt32()->Int32Value(); + obj->fd_ = Nan::To(info[0]).ToLocalChecked()->Value(); obj->callback_ = new Nan::Callback(info[1].As()); obj->Wrap(info.This()); obj->poll_handle_.data = obj; diff --git a/packages/serialport-util/packages/node-serialport/src/serialport.cpp b/packages/serialport-util/packages/node-serialport/src/serialport.cpp index 6f59bc9f9d..3eec33c1f0 100644 --- a/packages/serialport-util/packages/node-serialport/src/serialport.cpp +++ b/packages/serialport-util/packages/node-serialport/src/serialport.cpp @@ -87,19 +87,19 @@ v8::Local getValueFromObject(v8::Local options, std::stri } int getIntFromObject(v8::Local options, std::string key) { - return getValueFromObject(options, key)->ToInt32()->Int32Value(); + return Nan::To(getValueFromObject(options, key)).ToLocalChecked()->Value(); } bool getBoolFromObject(v8::Local options, std::string key) { - return getValueFromObject(options, key)->ToBoolean()->BooleanValue(); + return Nan::To(getValueFromObject(options, key)).ToLocalChecked()->Value(); } v8::Local getStringFromObj(v8::Local options, std::string key) { - return getValueFromObject(options, key)->ToString(); + return Nan::To(getValueFromObject(options, key)).ToLocalChecked(); } double getDoubleFromObject(v8::Local options, std::string key) { - return getValueFromObject(options, key)->ToNumber()->NumberValue(); + return Nan::To(getValueFromObject(options, key)).FromMaybe(0); } NAN_METHOD(Open) { @@ -162,7 +162,7 @@ void EIO_AfterOpen(uv_work_t* req) { argv[0] = Nan::Null(); argv[1] = Nan::New(data->result); - int fd = argv[1]->ToInt32()->Int32Value(); + int fd = Nan::To(argv[1]).ToLocalChecked()->Value(); newQForFD(fd); } @@ -177,7 +177,7 @@ NAN_METHOD(Update) { Nan::ThrowTypeError("First argument must be an int"); return; } - int fd = info[0]->ToInt32()->Int32Value(); + int fd = Nan::To(info[0]).ToLocalChecked()->Value(); // options if (!info[1]->IsObject()) { @@ -201,7 +201,7 @@ NAN_METHOD(Update) { memset(baton, 0, sizeof(ConnectionOptionsBaton)); baton->fd = fd; - baton->baudRate = Nan::Get(options, Nan::New("baudRate").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value(); + baton->baudRate = getIntFromObject(options, "baudRate"); baton->callback.Reset(info[2].As()); uv_work_t* req = new uv_work_t(); @@ -234,7 +234,7 @@ NAN_METHOD(Write) { Nan::ThrowTypeError("First argument must be an int"); return; } - int fd = info[0]->ToInt32()->Int32Value(); + int fd = Nan::To(info[0]).ToLocalChecked()->Value(); // buffer if (!info[1]->IsObject() || !node::Buffer::HasInstance(info[1])) { @@ -351,7 +351,7 @@ NAN_METHOD(Close) { VoidBaton* baton = new VoidBaton(); memset(baton, 0, sizeof(VoidBaton)); - baton->fd = info[0]->ToInt32()->Int32Value(); + baton->fd = Nan::To(info[0]).ToLocalChecked()->Value(); baton->callback.Reset(info[1].As()); uv_work_t* req = new uv_work_t(); @@ -457,7 +457,7 @@ NAN_METHOD(Flush) { Nan::ThrowTypeError("First argument must be an int"); return; } - int fd = info[0]->ToInt32()->Int32Value(); + int fd = Nan::To(info[0]).ToLocalChecked()->Value(); // callback if (!info[1]->IsFunction()) { @@ -501,7 +501,7 @@ NAN_METHOD(Set) { Nan::ThrowTypeError("First argument must be an int"); return; } - int fd = info[0]->ToInt32()->Int32Value(); + int fd = Nan::To(info[0]).ToLocalChecked()->Value(); // options if (!info[1]->IsObject()) { @@ -556,7 +556,7 @@ NAN_METHOD(Get) { Nan::ThrowTypeError("First argument must be an int"); return; } - int fd = info[0]->ToInt32()->Int32Value(); + int fd = Nan::To(info[0]).ToLocalChecked()->Value(); // callback if (!info[1]->IsFunction()) { @@ -608,7 +608,7 @@ NAN_METHOD(Drain) { Nan::ThrowTypeError("First argument must be an int"); return; } - int fd = info[0]->ToInt32()->Int32Value(); + int fd = Nan::To(info[0]).ToLocalChecked()->Value(); // callback if (!info[1]->IsFunction()) {