Skip to content

Commit

Permalink
Merge pull request #187 from DavidVujic/node_12_support
Browse files Browse the repository at this point in the history
Add Node 12 support
  • Loading branch information
DavidVujic authored Jul 16, 2019
2 parents dc798a3 + 40f979d commit 39e29f7
Show file tree
Hide file tree
Showing 10 changed files with 320 additions and 98 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: node_js
node_js:
- "10"
- "8"
- "10"
- "12"
os:
- linux
- osx
Expand All @@ -13,6 +14,7 @@ install:
- npm install
script:
- npm test
- npm run test-components
addons:
apt:
sources:
Expand Down
2 changes: 1 addition & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'/opt/local/include/zookeeper',
'<!(node -e "require(\'nan\')")'
],
'ldflags': ['-lzookeeper_st'],
'ldflags': ['-lzookeeper_st'],
}],
['OS=="mac"',{
'include_dirs': [
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@
"main": "lib/index",
"scripts": {
"build": "node-gyp configure build",
"build-components": "node-gyp configure build --directory=tests_components",
"install": "node ./scripts/prepublish.js && npm run build",
"lint": "eslint .",
"integrationtest": "pushd tests_integration; source ./test; popd",
"test": "npm run lint && tape ./tests/**/*.js | tap-spec"
"test": "npm run lint && tape ./tests/**/*.js | tap-spec",
"test-components": "npm run build-components && tape ./tests_components/**/*.js | tap-spec"
},
"engines": {
"node": ">=8.9.4"
Expand Down
49 changes: 49 additions & 0 deletions src/converters.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <v8.h>
#include "nan.h"

using namespace v8;

namespace nodezk {
Local<Object> toLocalObj(Local<Value> val) {
return Nan::To<Object>(val).ToLocalChecked();
}

Local<Value> toLocalVal(Local<Object> arg, Local<String> propertyName) {
Local<Value> val_local = arg->Get(Nan::GetCurrentContext(), propertyName).ToLocalChecked();
return val_local;
}

int32_t toInt(Local<Value> val_local) {
int32_t val = val_local->Int32Value(Nan::GetCurrentContext()).FromJust();

return val;
}

int32_t toInt(Local<Object> arg, Local<String> propertyName) {
Local<Value> val_local = toLocalVal(arg, propertyName);

return toInt(val_local);
}

bool toBool(Local<Value> val_local) {
return Nan::To<bool>(val_local).FromJust();
}

bool toBool(Local<Object> arg, Local<String> propertyName) {
Local<Value> val_local = toLocalVal(arg, propertyName);

return toBool(val_local);
}

Local<Value> convertUnixTimeToDate(double time) {
return Date::New(Isolate::GetCurrent()->GetCurrentContext(), time).ToLocalChecked();
}

Local<String> toString(Local<Value> val) {
return val->ToString(Nan::GetCurrentContext()).FromMaybe(Local<String>());
}

uint32_t toUint(Local<Value> val) {
return val->Uint32Value(Nan::GetCurrentContext()).FromJust();
}
}
Loading

0 comments on commit 39e29f7

Please sign in to comment.