From a98e73e781f1a51f7df35ebb8c7c2aa8f1aec661 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Mon, 3 May 2021 15:41:40 +0200 Subject: [PATCH] update bindings to support node 14 --- annoyindexwrapper.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/annoyindexwrapper.cc b/annoyindexwrapper.cc index 4a2b012..825856e 100644 --- a/annoyindexwrapper.cc +++ b/annoyindexwrapper.cc @@ -49,7 +49,7 @@ void AnnoyIndexWrapper::Init(v8::Local 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& info) { @@ -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(info[3]).FromJust(); } void AnnoyIndexWrapper::setNNReturnValues( @@ -270,8 +270,8 @@ void AnnoyIndexWrapper::setNNReturnValues( } jsResultObject = Nan::New(); - 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(); @@ -299,7 +299,7 @@ bool AnnoyIndexWrapper::getFloatArrayParam( Local jsArray = Local::Cast(info[paramIndex]); Local 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(); }