New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update calls to use contexts and convert Maybes into Checked values, … #3
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,15 +65,15 @@ class ZlibSyncInflate : public ObjectWrap { | |
|
||
static NAN_METHOD(Push) { | ||
ZlibSyncInflate* self = ObjectWrap::Unwrap<ZlibSyncInflate>(info.This()); | ||
|
||
auto context = info.GetIsolate()->GetCurrentContext(); | ||
Local<Object> buffer = Local<Object>::Cast(info[0]); | ||
int flush = Z_NO_FLUSH; | ||
if(info[1]->IsBoolean()) { | ||
if(info[1]->BooleanValue()) { | ||
if(info[1]->BooleanValue(context).ToChecked()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we can use the magic of |
||
flush = Z_FINISH; | ||
} | ||
} else if(info[1]->IsNumber()) { | ||
flush = info[1]->Int32Value(); | ||
flush = info[1]->Int32Value(context).ToChecked(); | ||
} | ||
|
||
z_stream* stream = &self->stream; | ||
|
@@ -153,7 +153,7 @@ class ZlibSyncInflate : public ObjectWrap { | |
if(!info.IsConstructCall()) { | ||
return Nan::ThrowTypeError("Use the new operator to construct a ZlibSyncInflate."); | ||
} | ||
|
||
auto context = info.GetIsolate()->GetCurrentContext(); | ||
unsigned int chunkSize = 16 * 1024; | ||
bool toString = false; | ||
int windowBits = 15; | ||
|
@@ -162,20 +162,20 @@ class ZlibSyncInflate : public ObjectWrap { | |
|
||
Local<Value> val = Nan::Get(options, Nan::New<String>("chunkSize").ToLocalChecked()).ToLocalChecked(); | ||
if(val->IsNumber()) { | ||
chunkSize = val->Int32Value(); | ||
chunkSize = val->Int32Value(context).ToChecked(); | ||
} | ||
|
||
val = Nan::Get(options, Nan::New<String>("to").ToLocalChecked()).ToLocalChecked(); | ||
if(val->IsString()) { | ||
std::string to = *String::Utf8Value(val->ToString()); | ||
std::string to = *Nan::Utf8String(val->ToString(context).ToLocalChecked()); | ||
if(to == "string") { | ||
toString = true; | ||
} | ||
} | ||
|
||
val = Nan::Get(options, Nan::New<String>("windowBits").ToLocalChecked()).ToLocalChecked(); | ||
if(val->IsNumber()) { | ||
windowBits = val->Int32Value(); | ||
windowBits = val->Int32Value(context).ToChecked(); | ||
} | ||
} | ||
|
||
|
@@ -187,7 +187,7 @@ class ZlibSyncInflate : public ObjectWrap { | |
|
||
static NAN_MODULE_INIT(Init) { | ||
Nan::HandleScope scope; | ||
|
||
auto context = Nan::GetCurrentContext(); | ||
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New); | ||
tpl->SetClassName(Nan::New<String>("ZlibSyncInflate").ToLocalChecked()); | ||
tpl->InstanceTemplate()->SetInternalFieldCount(1); | ||
|
@@ -201,7 +201,7 @@ class ZlibSyncInflate : public ObjectWrap { | |
Nan::SetAccessor(itpl, Nan::New<String>("result").ToLocalChecked(), GetResult); | ||
Nan::SetAccessor(itpl, Nan::New<String>("windowBits").ToLocalChecked(), GetWindowBits); | ||
|
||
target->Set(Nan::New<String>("Inflate").ToLocalChecked(), tpl->GetFunction()); | ||
target->Set(Nan::New<String>("Inflate").ToLocalChecked(), tpl->GetFunction(context).ToLocalChecked()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This thing is deprecated too, could add |
||
} | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're using
nan
anyway, let's stick withNan::GetCurrentContext()
for this and the other context.Also,
Local<Context>
is a bit more readable thanauto
.