Skip to content

Commit

Permalink
Fix compilation on node 12 (#3)
Browse files Browse the repository at this point in the history
Fixes #4
  • Loading branch information
churchofthought authored and abalabahaha committed Aug 2, 2019
1 parent 1302a06 commit 14c887d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/zlib_sync.cc
Expand Up @@ -65,15 +65,15 @@ class ZlibSyncInflate : public ObjectWrap {

static NAN_METHOD(Push) {
ZlibSyncInflate* self = ObjectWrap::Unwrap<ZlibSyncInflate>(info.This());

Local<Context> context = Nan::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()) {
flush = Z_FINISH;
}
} else if(info[1]->IsNumber()) {
flush = info[1]->Int32Value();
flush = info[1]->Int32Value(context).ToChecked();
}

z_stream* stream = &self->stream;
Expand Down Expand Up @@ -153,7 +153,7 @@ class ZlibSyncInflate : public ObjectWrap {
if(!info.IsConstructCall()) {
return Nan::ThrowTypeError("Use the new operator to construct a ZlibSyncInflate.");
}

Local<Context> context = Nan::GetCurrentContext();
unsigned int chunkSize = 16 * 1024;
bool toString = false;
int windowBits = 15;
Expand All @@ -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();
}
}

Expand All @@ -187,7 +187,7 @@ class ZlibSyncInflate : public ObjectWrap {

static NAN_MODULE_INIT(Init) {
Nan::HandleScope scope;

Local<Context> context = Nan::GetCurrentContext();
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
tpl->SetClassName(Nan::New<String>("ZlibSyncInflate").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);
Expand All @@ -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());
}
};

Expand Down

0 comments on commit 14c887d

Please sign in to comment.