Skip to content

Commit 39e29f7

Browse files
authored
Merge pull request #187 from DavidVujic/node_12_support
Add Node 12 support
2 parents dc798a3 + 40f979d commit 39e29f7

10 files changed

+320
-98
lines changed

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
language: node_js
22
node_js:
3-
- "10"
43
- "8"
4+
- "10"
5+
- "12"
56
os:
67
- linux
78
- osx
@@ -13,6 +14,7 @@ install:
1314
- npm install
1415
script:
1516
- npm test
17+
- npm run test-components
1618
addons:
1719
apt:
1820
sources:

binding.gyp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'/opt/local/include/zookeeper',
1616
'<!(node -e "require(\'nan\')")'
1717
],
18-
'ldflags': ['-lzookeeper_st'],
18+
'ldflags': ['-lzookeeper_st'],
1919
}],
2020
['OS=="mac"',{
2121
'include_dirs': [

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@
4646
"main": "lib/index",
4747
"scripts": {
4848
"build": "node-gyp configure build",
49+
"build-components": "node-gyp configure build --directory=tests_components",
4950
"install": "node ./scripts/prepublish.js && npm run build",
5051
"lint": "eslint .",
5152
"integrationtest": "pushd tests_integration; source ./test; popd",
52-
"test": "npm run lint && tape ./tests/**/*.js | tap-spec"
53+
"test": "npm run lint && tape ./tests/**/*.js | tap-spec",
54+
"test-components": "npm run build-components && tape ./tests_components/**/*.js | tap-spec"
5355
},
5456
"engines": {
5557
"node": ">=8.9.4"

src/converters.hpp

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include <v8.h>
2+
#include "nan.h"
3+
4+
using namespace v8;
5+
6+
namespace nodezk {
7+
Local<Object> toLocalObj(Local<Value> val) {
8+
return Nan::To<Object>(val).ToLocalChecked();
9+
}
10+
11+
Local<Value> toLocalVal(Local<Object> arg, Local<String> propertyName) {
12+
Local<Value> val_local = arg->Get(Nan::GetCurrentContext(), propertyName).ToLocalChecked();
13+
return val_local;
14+
}
15+
16+
int32_t toInt(Local<Value> val_local) {
17+
int32_t val = val_local->Int32Value(Nan::GetCurrentContext()).FromJust();
18+
19+
return val;
20+
}
21+
22+
int32_t toInt(Local<Object> arg, Local<String> propertyName) {
23+
Local<Value> val_local = toLocalVal(arg, propertyName);
24+
25+
return toInt(val_local);
26+
}
27+
28+
bool toBool(Local<Value> val_local) {
29+
return Nan::To<bool>(val_local).FromJust();
30+
}
31+
32+
bool toBool(Local<Object> arg, Local<String> propertyName) {
33+
Local<Value> val_local = toLocalVal(arg, propertyName);
34+
35+
return toBool(val_local);
36+
}
37+
38+
Local<Value> convertUnixTimeToDate(double time) {
39+
return Date::New(Isolate::GetCurrent()->GetCurrentContext(), time).ToLocalChecked();
40+
}
41+
42+
Local<String> toString(Local<Value> val) {
43+
return val->ToString(Nan::GetCurrentContext()).FromMaybe(Local<String>());
44+
}
45+
46+
uint32_t toUint(Local<Value> val) {
47+
return val->Uint32Value(Nan::GetCurrentContext()).FromJust();
48+
}
49+
}

0 commit comments

Comments
 (0)