From 5074fbac92c6b19125e809a7853f7e635b9a00a1 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Tue, 20 Oct 2020 16:27:51 +0200 Subject: [PATCH] src: Port to node-14 Relate-to: https://v8docs.nodesource.com/node-14.1/d3/d32/classv8_1_1_array.html Relate-to: https://github.com/rzr/generic-sensors-webthings/issues/20 Change-Id: I1ae50057f7815674f4f48f658a6b3262972a81dd Signed-off-by: Philippe Coval --- src/i2c.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/i2c.cc b/src/i2c.cc index 54a73d0..9f03b9e 100644 --- a/src/i2c.cc +++ b/src/i2c.cc @@ -61,7 +61,11 @@ void Scan(const Nan::FunctionCallbackInfo& info) { if (res >= 0) { res = i; } +#if V8_MAJOR_VERSION >= 8 + results->Set(Nan::GetCurrentContext(), i, Nan::New(res)); +#else results->Set(i, Nan::New(res)); +#endif } setAddress(addr); @@ -123,7 +127,11 @@ void Read(const Nan::FunctionCallbackInfo& 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(buf[i])); +#else data->Set(i, Nan::New(buf[i])); +#endif } } delete[] buf;