Skip to content

Commit

Permalink
src: Port to node-14
Browse files Browse the repository at this point in the history
Relate-to: https://v8docs.nodesource.com/node-14.1/d3/d32/classv8_1_1_array.html
Relate-to: rzr/generic-sensors-webthings#20
Change-Id: I1ae50057f7815674f4f48f658a6b3262972a81dd
Signed-off-by: Philippe Coval <[email protected]>
  • Loading branch information
rzr committed Oct 20, 2020
1 parent 7ab77ad commit 9a17aa5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/i2c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ void Scan(const Nan::FunctionCallbackInfo<v8::Value>& info) {
if (res >= 0) {
res = i;
}
#if V8_MAJOR_VERSION >= 8
results->Set(Nan::GetCurrentContext(), i, Nan::New<Integer>(res));
#else
results->Set(i, Nan::New<Integer>(res));
#endif
}

setAddress(addr);
Expand Down Expand Up @@ -123,7 +127,11 @@ void Read(const Nan::FunctionCallbackInfo<v8::Value>& info) {
err = Nan::Error(Nan::New("Cannot read from device").ToLocalChecked());
} else {
for (int i = 0; i < len; ++i) {
#if V8_MAJOR_VERSION >= 8
data->Set(Nan::GetCurrentContext(), i, Nan::New<Integer>(buf[i]));
#else
data->Set(i, Nan::New<Integer>(buf[i]));
#endif
}
}
delete[] buf;
Expand Down

0 comments on commit 9a17aa5

Please sign in to comment.