Skip to content

Commit 8c093b8

Browse files
authored
Fix compatibility to Node.js 13 (#121)
1 parent 732beda commit 8c093b8

7 files changed

Lines changed: 17 additions & 8 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ node_js:
33
- "8"
44
- "10"
55
- "12"
6+
- "13"
67
cache:
78
npm
89
before_install:

1_hello_world/nan/hello.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ void Method(const Nan::FunctionCallbackInfo<v8::Value>& info) {
66

77
void Init(v8::Local<v8::Object> exports) {
88
v8::Local<v8::Context> context = exports->CreationContext();
9-
exports->Set(Nan::New("hello").ToLocalChecked(),
9+
exports->Set(context,
10+
Nan::New("hello").ToLocalChecked(),
1011
Nan::New<v8::FunctionTemplate>(Method)
1112
->GetFunction(context)
1213
.ToLocalChecked());

2_function_arguments/nan/addon.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ void Add(const Nan::FunctionCallbackInfo<v8::Value>& info) {
2222

2323
void Init(v8::Local<v8::Object> exports) {
2424
v8::Local<v8::Context> context = exports->CreationContext();
25-
exports->Set(Nan::New("add").ToLocalChecked(),
25+
exports->Set(context,
26+
Nan::New("add").ToLocalChecked(),
2627
Nan::New<v8::FunctionTemplate>(Add)
2728
->GetFunction(context)
2829
.ToLocalChecked());

4_object_factory/nan/addon.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
void CreateObject(const Nan::FunctionCallbackInfo<v8::Value>& info) {
44
v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
55
v8::Local<v8::Object> obj = Nan::New<v8::Object>();
6-
obj->Set(Nan::New("msg").ToLocalChecked(),
6+
obj->Set(context,
7+
Nan::New("msg").ToLocalChecked(),
78
info[0]->ToString(context).ToLocalChecked());
89

910
info.GetReturnValue().Set(obj);
1011
}
1112

1213
void Init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module) {
1314
v8::Local<v8::Context> context = exports->CreationContext();
14-
module->Set(Nan::New("exports").ToLocalChecked(),
15+
module->Set(context,
16+
Nan::New("exports").ToLocalChecked(),
1517
Nan::New<v8::FunctionTemplate>(CreateObject)
1618
->GetFunction(context)
1719
.ToLocalChecked());

6_object_wrap/nan/myobject.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ void MyObject::Init(v8::Local<v8::Object> exports) {
2121
Nan::SetPrototypeMethod(tpl, "multiply", Multiply);
2222

2323
constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
24-
exports->Set(Nan::New("MyObject").ToLocalChecked(),
24+
exports->Set(context,
25+
Nan::New("MyObject").ToLocalChecked(),
2526
tpl->GetFunction(context).ToLocalChecked());
2627
}
2728

7_factory_wrap/nan/addon.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ void InitAll(v8::Local<v8::Object> exports, v8::Local<v8::Object> module) {
1212

1313
MyObject::Init();
1414

15-
module->Set(Nan::New("exports").ToLocalChecked(),
15+
module->Set(context,
16+
Nan::New("exports").ToLocalChecked(),
1617
Nan::New<v8::FunctionTemplate>(CreateObject)
1718
->GetFunction(context)
1819
.ToLocalChecked());

8_passing_wrapped/nan/addon.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ void InitAll(v8::Local<v8::Object> exports) {
2323

2424
MyObject::Init();
2525

26-
exports->Set(Nan::New("createObject").ToLocalChecked(),
26+
exports->Set(context,
27+
Nan::New("createObject").ToLocalChecked(),
2728
Nan::New<v8::FunctionTemplate>(CreateObject)
2829
->GetFunction(context)
2930
.ToLocalChecked());
3031

31-
exports->Set(Nan::New("add").ToLocalChecked(),
32+
exports->Set(context,
33+
Nan::New("add").ToLocalChecked(),
3234
Nan::New<v8::FunctionTemplate>(Add)
3335
->GetFunction(context)
3436
.ToLocalChecked());

0 commit comments

Comments
 (0)