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;