Update Node library dependencies and change deprecated function calls
diff --git a/package.json b/package.json
index b06e475..eaac9d7 100644
--- a/package.json
+++ b/package.json
@@ -25,24 +25,26 @@
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test",
"install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build"
},
- "bundledDependencies": ["node-pre-gyp"],
+ "bundledDependencies": [
+ "node-pre-gyp"
+ ],
"dependencies": {
"arguejs": "^0.2.3",
- "lodash": "^3.9.3",
+ "lodash": "^4.15.0",
"nan": "^2.0.0",
- "protobufjs": "^4.0.0"
+ "node-pre-gyp": "^0.6.0",
+ "protobufjs": "^5.0.0"
},
"devDependencies": {
- "async": "^1.5.0",
+ "async": "^2.0.1",
"google-auth-library": "^0.9.2",
"google-protobuf": "^3.0.0",
- "istanbul": "^0.3.21",
+ "istanbul": "^0.4.4",
"jsdoc": "^3.3.2",
"jshint": "^2.5.0",
"minimist": "^1.1.0",
- "mocha": "^2.3.4",
- "mocha-jenkins-reporter": "^0.1.9",
- "mustache": "^2.0.0",
+ "mocha": "^3.0.2",
+ "mocha-jenkins-reporter": "^0.2.3",
"poisson-process": "^0.2.1"
},
"engines": {
@@ -50,11 +52,10 @@
},
"binary": {
"module_name": "grpc_node",
- "module_path": "./build/Release/",
+ "module_path": "src/node/extension_binary",
"host": "https://storage.googleapis.com/",
"remote_path": "grpc-precompiled-binaries/node/{name}/v{version}",
- "package_name": "{node_abi}-{platform}-{arch}.tar.gz",
- "module_path": "src/node/extension_binary"
+ "package_name": "{node_abi}-{platform}-{arch}.tar.gz"
},
"files": [
"LICENSE",
@@ -75,7 +76,7 @@
],
"main": "src/node/index.js",
"license": "BSD-3-Clause",
- "jshintConfig" : {
+ "jshintConfig": {
"bitwise": true,
"curly": true,
"eqeqeq": true,
diff --git a/src/node/ext/byte_buffer.cc b/src/node/ext/byte_buffer.cc
index a3f678f..ad7d0ec 100644
--- a/src/node/ext/byte_buffer.cc
+++ b/src/node/ext/byte_buffer.cc
@@ -44,8 +44,8 @@
namespace grpc {
namespace node {
+using Nan::MaybeLocal;
-using v8::Context;
using v8::Function;
using v8::Local;
using v8::Object;
@@ -89,15 +89,19 @@
Local<Value> MakeFastBuffer(Local<Value> slowBuffer) {
Nan::EscapableHandleScope scope;
Local<Object> globalObj = Nan::GetCurrentContext()->Global();
+ MaybeLocal<Value> constructorValue = Nan::Get(
+ globalObj, Nan::New("Buffer").ToLocalChecked());
Local<Function> bufferConstructor = Local<Function>::Cast(
- globalObj->Get(Nan::New("Buffer").ToLocalChecked()));
- Local<Value> consArgs[3] = {
+ constructorValue.ToLocalChecked());
+ const int argc = 3;
+ Local<Value> consArgs[argc] = {
slowBuffer,
Nan::New<Number>(::node::Buffer::Length(slowBuffer)),
Nan::New<Number>(0)
};
- Local<Object> fastBuffer = bufferConstructor->NewInstance(3, consArgs);
- return scope.Escape(fastBuffer);
+ MaybeLocal<Object> fastBuffer = Nan::NewInstance(bufferConstructor,
+ argc, consArgs);
+ return scope.Escape(fastBuffer.ToLocalChecked());
}
} // namespace node
} // namespace grpc
diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc
index 9f023b5..fbab40d 100644
--- a/src/node/ext/call.cc
+++ b/src/node/ext/call.cc
@@ -613,16 +613,16 @@
return Nan::ThrowTypeError("Call's fourth argument must be a string");
}
call = new Call(wrapped_call);
- info.This()->SetHiddenValue(Nan::New("channel_").ToLocalChecked(),
- channel_object);
+ Nan::Set(info.This(), Nan::New("channel_").ToLocalChecked(),
+ channel_object);
}
call->Wrap(info.This());
info.GetReturnValue().Set(info.This());
} else {
const int argc = 4;
Local<Value> argv[argc] = {info[0], info[1], info[2], info[3]};
- MaybeLocal<Object> maybe_instance = constructor->GetFunction()->NewInstance(
- argc, argv);
+ MaybeLocal<Object> maybe_instance = Nan::NewInstance(
+ constructor->GetFunction(), argc, argv);
if (maybe_instance.IsEmpty()) {
// There's probably a pending exception
return;
diff --git a/src/node/ext/channel.cc b/src/node/ext/channel.cc
index 00fcca6..db46533 100644
--- a/src/node/ext/channel.cc
+++ b/src/node/ext/channel.cc
@@ -206,8 +206,8 @@
} else {
const int argc = 3;
Local<Value> argv[argc] = {info[0], info[1], info[2]};
- MaybeLocal<Object> maybe_instance = constructor->GetFunction()->NewInstance(
- argc, argv);
+ MaybeLocal<Object> maybe_instance = Nan::NewInstance(
+ constructor->GetFunction(), argc, argv);
if (maybe_instance.IsEmpty()) {
// There's probably a pending exception
return;
diff --git a/src/node/ext/node_grpc.cc b/src/node/ext/node_grpc.cc
index 745b502..ec81356 100644
--- a/src/node/ext/node_grpc.cc
+++ b/src/node/ext/node_grpc.cc
@@ -261,8 +261,8 @@
Nan::HandleScope scope;
Local<Object> log_verbosity = Nan::New<Object>();
Nan::Set(exports, Nan::New("logVerbosity").ToLocalChecked(), log_verbosity);
- Local<Value> DEBUG(Nan::New<Uint32, uint32_t>(GPR_LOG_SEVERITY_DEBUG));
- Nan::Set(log_verbosity, Nan::New("DEBUG").ToLocalChecked(), DEBUG);
+ Local<Value> DEBUG_LOG(Nan::New<Uint32, uint32_t>(GPR_LOG_SEVERITY_DEBUG));
+ Nan::Set(log_verbosity, Nan::New("DEBUG").ToLocalChecked(), DEBUG_LOG);
Local<Value> INFO(Nan::New<Uint32, uint32_t>(GPR_LOG_SEVERITY_INFO));
Nan::Set(log_verbosity, Nan::New("INFO").ToLocalChecked(), INFO);
Local<Value> LOG_ERROR(Nan::New<Uint32, uint32_t>(GPR_LOG_SEVERITY_ERROR));
diff --git a/src/node/ext/server.cc b/src/node/ext/server.cc
index dd1b777..73c5ef2 100644
--- a/src/node/ext/server.cc
+++ b/src/node/ext/server.cc
@@ -169,7 +169,7 @@
const int argc = 1;
Local<Value> argv[argc] = {info[0]};
MaybeLocal<Object> maybe_instance =
- constructor->GetFunction()->NewInstance(argc, argv);
+ Nan::NewInstance(constructor->GetFunction(), argc, argv);
if (maybe_instance.IsEmpty()) {
// There's probably a pending exception
return;
diff --git a/src/node/src/common.js b/src/node/src/common.js
index 22159dd..c6c6d59 100644
--- a/src/node/src/common.js
+++ b/src/node/src/common.js
@@ -141,7 +141,7 @@
binaryAsBase64 = options.binaryAsBase64;
longsAsStrings = options.longsAsStrings;
}
- return _.object(_.map(service.children, function(method) {
+ return _.fromPairs(_.map(service.children, function(method) {
return [_.camelCase(method.name), {
path: prefix + method.name,
requestStream: method.requestStream,
diff --git a/templates/package.json.template b/templates/package.json.template
index e9596d4..0829517 100644
--- a/templates/package.json.template
+++ b/templates/package.json.template
@@ -27,24 +27,26 @@
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test",
"install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build"
},
- "bundledDependencies": ["node-pre-gyp"],
+ "bundledDependencies": [
+ "node-pre-gyp"
+ ],
"dependencies": {
"arguejs": "^0.2.3",
- "lodash": "^3.9.3",
+ "lodash": "^4.15.0",
"nan": "^2.0.0",
- "protobufjs": "^4.0.0"
+ "node-pre-gyp": "^0.6.0",
+ "protobufjs": "^5.0.0"
},
"devDependencies": {
- "async": "^1.5.0",
+ "async": "^2.0.1",
"google-auth-library": "^0.9.2",
"google-protobuf": "^3.0.0",
- "istanbul": "^0.3.21",
+ "istanbul": "^0.4.4",
"jsdoc": "^3.3.2",
"jshint": "^2.5.0",
"minimist": "^1.1.0",
- "mocha": "^2.3.4",
- "mocha-jenkins-reporter": "^0.1.9",
- "mustache": "^2.0.0",
+ "mocha": "^3.0.2",
+ "mocha-jenkins-reporter": "^0.2.3",
"poisson-process": "^0.2.1"
},
"engines": {
@@ -52,11 +54,10 @@
},
"binary": {
"module_name": "grpc_node",
- "module_path": "./build/Release/",
+ "module_path": "src/node/extension_binary",
"host": "https://storage.googleapis.com/",
"remote_path": "grpc-precompiled-binaries/node/{name}/v{version}",
- "package_name": "{node_abi}-{platform}-{arch}.tar.gz",
- "module_path": "src/node/extension_binary"
+ "package_name": "{node_abi}-{platform}-{arch}.tar.gz"
},
"files": [
"LICENSE",
@@ -77,7 +78,7 @@
],
"main": "src/node/index.js",
"license": "BSD-3-Clause",
- "jshintConfig" : {
+ "jshintConfig": {
"bitwise": true,
"curly": true,
"eqeqeq": true,