Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Fix for v8 in node 12.
Browse files Browse the repository at this point in the history
Signed-off-by: Hal Gentz <[email protected]>
  • Loading branch information
goddessfreya committed Oct 24, 2019
1 parent a03caf3 commit 613ff91
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 16 additions & 6 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,15 @@ class Spellchecker : public Nan::ObjectWrap {
uint32_t start = iter->start, end = iter->end;

Local<Object> misspelled_range = Nan::New<Object>();
misspelled_range->Set(Nan::New("start").ToLocalChecked(), Nan::New<Integer>(start));
misspelled_range->Set(Nan::New("end").ToLocalChecked(), Nan::New<Integer>(end));
result->Set(index, misspelled_range);
{
Isolate* isolate = misspelled_range->GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
misspelled_range->Set(context, Nan::New("start").ToLocalChecked(), Nan::New<Integer>(start)).Check();
misspelled_range->Set(context, Nan::New("end").ToLocalChecked(), Nan::New<Integer>(end)).Check();
}
Isolate* isolate = result->GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
result->Set(context, index, misspelled_range).Check();
}
}

Expand Down Expand Up @@ -220,7 +226,9 @@ class Spellchecker : public Nan::ObjectWrap {
Local<Array> result = Nan::New<Array>(dictionaries.size());
for (size_t i = 0; i < dictionaries.size(); ++i) {
const std::string& dict = dictionaries[i];
result->Set(i, Nan::New(dict.data(), dict.size()).ToLocalChecked());
Isolate* isolate = result->GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
result->Set(context, i, Nan::New(dict.data(), dict.size()).ToLocalChecked()).Check();
}

info.GetReturnValue().Set(result);
Expand All @@ -246,7 +254,9 @@ class Spellchecker : public Nan::ObjectWrap {
const std::string& word = corrections[i];

Nan::MaybeLocal<String> val = Nan::New<String>(word.data(), word.size());
result->Set(i, val.ToLocalChecked());
Isolate* isolate = result->GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
result->Set(context, i, val.ToLocalChecked()).Check();
}

info.GetReturnValue().Set(result);
Expand Down Expand Up @@ -286,7 +296,7 @@ class Spellchecker : public Nan::ObjectWrap {

Isolate* isolate = exports->GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
exports->Set(Nan::New("Spellchecker").ToLocalChecked(), tpl->GetFunction(context).ToLocalChecked());
exports->Set(context, Nan::New("Spellchecker").ToLocalChecked(), tpl->GetFunction(context).ToLocalChecked()).Check();
}
};

Expand Down
12 changes: 9 additions & 3 deletions src/worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ void CheckSpellingWorker::HandleOKCallback() {
uint32_t start = iter->start, end = iter->end;

Local<Object> misspelled_range = Nan::New<Object>();
misspelled_range->Set(Nan::New("start").ToLocalChecked(), Nan::New<Integer>(start));
misspelled_range->Set(Nan::New("end").ToLocalChecked(), Nan::New<Integer>(end));
result->Set(index, misspelled_range);
{
Isolate* isolate = misspelled_range->GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
misspelled_range->Set(context, Nan::New("start").ToLocalChecked(), Nan::New<Integer>(start)).Check();
misspelled_range->Set(context, Nan::New("end").ToLocalChecked(), Nan::New<Integer>(end)).Check();
}
Isolate* isolate = result->GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
result->Set(context, index, misspelled_range).Check();
}

Local<Value> argv[] = { Nan::Null(), result };
Expand Down

0 comments on commit 613ff91

Please sign in to comment.