diff --git a/package.json b/package.json index c35ba21..916e785 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ "test": "mocha" }, "dependencies": { - "bindings": "^1.4.0", - "nan": "^2.12.1" + "bindings": "^1.5.0", + "nan": "^2.14.0" }, "devDependencies": { "mocha": "^6.0.0", diff --git a/src/cardreader.cpp b/src/cardreader.cpp index 98c6016..ad9c4e5 100644 --- a/src/cardreader.cpp +++ b/src/cardreader.cpp @@ -58,10 +58,8 @@ void CardReader::init(Local target) { Nan::SetPrototypeTemplate(tpl, "SCARD_UNPOWER_CARD", Nan::New(SCARD_UNPOWER_CARD)); Nan::SetPrototypeTemplate(tpl, "SCARD_EJECT_CARD", Nan::New(SCARD_EJECT_CARD)); - Local context = Nan::GetCurrentContext(); - - constructor.Reset(tpl->GetFunction(context).ToLocalChecked()); - target->Set(Nan::New("CardReader").ToLocalChecked(), tpl->GetFunction(context).ToLocalChecked()); + constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked()); + target->Set(Nan::New("CardReader").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } CardReader::CardReader(const std::string &reader_name): m_card_context(0), @@ -136,11 +134,9 @@ NAN_METHOD(CardReader::Connect) { return Nan::ThrowError("Third argument must be a callback function"); } - Local context = Nan::GetCurrentContext(); - ConnectInput* ci = new ConnectInput(); - ci->share_mode = info[0]->Uint32Value(context).FromJust(); - ci->pref_protocol = info[1]->Uint32Value(context).FromJust(); + ci->share_mode = Nan::To(info[0]).FromJust(); + ci->pref_protocol = Nan::To(info[1]).FromJust(); Local cb = Local::Cast(info[2]); // This creates our work request, including the libuv struct. @@ -174,9 +170,7 @@ NAN_METHOD(CardReader::Disconnect) { return Nan::ThrowError("Second argument must be a callback function"); } - Local context = Nan::GetCurrentContext(); - - DWORD disposition = info[0]->Uint32Value(context).FromJust(); + DWORD disposition = Nan::To(info[0]).FromJust(); Local cb = Local::Cast(info[1]); // This creates our work request, including the libuv struct. @@ -222,11 +216,9 @@ NAN_METHOD(CardReader::Transmit) { return Nan::ThrowError("Fourth argument must be a callback function"); } - Local context = Nan::GetCurrentContext(); - Local buffer_data = Nan::To(info[0]).ToLocalChecked(); - uint32_t out_len = info[1]->Uint32Value(context).FromJust(); - uint32_t protocol = info[2]->Uint32Value(context).FromJust(); + uint32_t out_len = Nan::To(info[1]).FromJust(); + uint32_t protocol = Nan::To(info[2]).FromJust(); Local cb = Local::Cast(info[3]); @@ -280,10 +272,8 @@ NAN_METHOD(CardReader::Control) { return Nan::ThrowError("Fourth argument must be a callback function"); } - Local context = Nan::GetCurrentContext(); - Local in_buf = Nan::To(info[0]).ToLocalChecked(); - DWORD control_code = info[1]->Uint32Value(context).FromJust(); + DWORD control_code = Nan::To(info[1]).FromJust(); Local out_buf = Nan::To(info[2]).ToLocalChecked(); Local cb = Local::Cast(info[3]); diff --git a/src/pcsclite.cpp b/src/pcsclite.cpp index a35d0b4..33aa38a 100644 --- a/src/pcsclite.cpp +++ b/src/pcsclite.cpp @@ -8,8 +8,6 @@ Nan::Persistent PCSCLite::constructor; void PCSCLite::init(Local target) { - Local context = Nan::GetCurrentContext(); - // Prepare constructor template Local tpl = Nan::New(New); tpl->SetClassName(Nan::New("PCSCLite").ToLocalChecked()); @@ -19,8 +17,8 @@ void PCSCLite::init(Local target) { Nan::SetPrototypeTemplate(tpl, "close", Nan::New(Close)); - constructor.Reset(tpl->GetFunction(context).ToLocalChecked()); - target->Set(Nan::New("PCSCLite").ToLocalChecked(), tpl->GetFunction(context).ToLocalChecked()); + constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked()); + target->Set(Nan::New("PCSCLite").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } PCSCLite::PCSCLite(): m_card_context(0), diff --git a/yarn.lock b/yarn.lock index 75fb004..1bbe87a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -70,10 +70,10 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= -bindings@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.4.0.tgz#909efa49f2ebe07ecd3cb136778f665052040127" - integrity sha512-7znEVX22Djn+nYjxCWKDne0RRloa9XfYa84yk3s+HkE3LpDYZmhArYr9O9huBoHY3/oXispx5LorIX7Sl2CgSQ== +bindings@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" + integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== dependencies: file-uri-to-path "1.0.0" @@ -428,10 +428,10 @@ ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -nan@^2.12.1: - version "2.12.1" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.12.1.tgz#7b1aa193e9aa86057e3c7bbd0ac448e770925552" - integrity sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw== +nan@^2.14.0: + version "2.14.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c" + integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg== nise@^1.5.2: version "1.5.3"