Skip to content

Commit

Permalink
Remove v8 deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
reconbot committed Jul 24, 2018
1 parent d5b50f2 commit ecda71b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ NAN_METHOD(ReadPoller::New) {
}

ReadPoller* obj = new ReadPoller();
obj->fd_ = info[0]->ToInt32()->Int32Value();
obj->fd_ = Nan::To<v8::Int32>(info[0]).ToLocalChecked()->Value();
obj->callback_ = new Nan::Callback(info[1].As<v8::Function>());
obj->Wrap(info.This());
obj->poll_handle_.data = obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ v8::Local<v8::Value> getValueFromObject(v8::Local<v8::Object> options, std::stri
}

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

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

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

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

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

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

Expand All @@ -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<v8::Int32>(info[0]).ToLocalChecked()->Value();

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

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

uv_work_t* req = new uv_work_t();
Expand Down Expand Up @@ -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<v8::Int32>(info[0]).ToLocalChecked()->Value();

// buffer
if (!info[1]->IsObject() || !node::Buffer::HasInstance(info[1])) {
Expand Down Expand Up @@ -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<v8::Int32>(info[0]).ToLocalChecked()->Value();
baton->callback.Reset(info[1].As<v8::Function>());

uv_work_t* req = new uv_work_t();
Expand Down Expand Up @@ -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<v8::Int32>(info[0]).ToLocalChecked()->Value();

// callback
if (!info[1]->IsFunction()) {
Expand Down Expand Up @@ -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<v8::Int32>(info[0]).ToLocalChecked()->Value();

// options
if (!info[1]->IsObject()) {
Expand Down Expand Up @@ -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<v8::Int32>(info[0]).ToLocalChecked()->Value();

// callback
if (!info[1]->IsFunction()) {
Expand Down Expand Up @@ -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<v8::Int32>(info[0]).ToLocalChecked()->Value();

// callback
if (!info[1]->IsFunction()) {
Expand Down

0 comments on commit ecda71b

Please sign in to comment.