Skip to content
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 bindings to support node 14 #13

Merged
merged 1 commit into from
May 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions annoyindexwrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void AnnoyIndexWrapper::Init(v8::Local<v8::Object> exports) {
Nan::SetPrototypeMethod(tpl, "getDistance", GetDistance);

constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked());
exports->Set(Nan::New("Annoy").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked());
Nan::Set(exports, Nan::New("Annoy").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked());
}

void AnnoyIndexWrapper::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
Expand Down Expand Up @@ -243,7 +243,7 @@ void AnnoyIndexWrapper::getSupplementaryGetNNsParams(
searchK = info[2]->IsUndefined() ? -1 : info[2]->NumberValue(context).FromJust();

// Get out include distances flag.
includeDistances = info[3]->IsUndefined() ? false : info[3]->BooleanValue(context).FromJust();
includeDistances = info[3]->IsUndefined() ? false : Nan::To<bool>(info[3]).FromJust();
}

void AnnoyIndexWrapper::setNNReturnValues(
Expand All @@ -270,8 +270,8 @@ void AnnoyIndexWrapper::setNNReturnValues(
}

jsResultObject = Nan::New<Object>();
jsResultObject->Set(Nan::New("neighbors").ToLocalChecked(), jsNNIndexes);
jsResultObject->Set(Nan::New("distances").ToLocalChecked(), jsDistancesArray);
Nan::Set(jsResultObject, Nan::New("neighbors").ToLocalChecked(), jsNNIndexes);
Nan::Set(jsResultObject, Nan::New("distances").ToLocalChecked(), jsDistancesArray);
}
else {
jsResultObject = jsNNIndexes.As<Object>();
Expand Down Expand Up @@ -299,7 +299,7 @@ bool AnnoyIndexWrapper::getFloatArrayParam(
Local<Array> jsArray = Local<Array>::Cast(info[paramIndex]);
Local<Value> val;
for (unsigned int i = 0; i < jsArray->Length(); i++) {
val = jsArray->Get(i);
val = Nan::Get(jsArray, i).ToLocalChecked();
// printf("Adding item to array: %f\n", (float)val->NumberValue(Nan::GetCurrentContext()).FromJust());
vec[i] = (float)val->NumberValue(Nan::GetCurrentContext()).FromJust();
}
Expand Down