From f293d719a7e6296fcec0ecf54ba56e8a062893d8 Mon Sep 17 00:00:00 2001 From: Benjamin Hanes Date: Fri, 11 Mar 2016 10:28:06 -0500 Subject: [PATCH] Upgrading to Nan 2.2.0 for compatibility with newer versions of Node --- package.json | 4 ++-- src/objhash.cc | 23 ++++++++++------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 8076336..8196e9f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "objhash", "main": "objhash", - "version": "1.0.5", + "version": "1.0.6", "description": "Retrieve a node.js object's V8 identity hash", "repository": { "type": "git", @@ -31,6 +31,6 @@ }, "dependencies": { "bindings": "^1.2.1", - "nan": "^1.4.1" + "nan": "^2.2.0" } } diff --git a/src/objhash.cc b/src/objhash.cc index b91706d..8918a1a 100644 --- a/src/objhash.cc +++ b/src/objhash.cc @@ -1,23 +1,20 @@ #include -using namespace v8; - -NAN_METHOD(Ident) { - NanScope(); - if (args.Length() < 1) { - NanReturnUndefined(); - } else if (args[0]->IsObject()) { - int hash = args[0]->ToObject()->GetIdentityHash(); - NanReturnValue(NanNew(hash)); +void Method(const Nan::FunctionCallbackInfo& info) { + if (info.Length() < 1) { + info.GetReturnValue().Set(Nan::Undefined()); + } else if (info[0]->IsObject()) { + int hash = info[0]->ToObject()->GetIdentityHash(); + info.GetReturnValue().Set(Nan::New(hash)); } else { - NanReturnValue(args[0]); + info.GetReturnValue().Set(info[0]); } } -void Init(Handle exports) { +void Init(v8::Handle exports) { exports->Set( - NanNew("ident"), - NanNew(Ident)->GetFunction() + Nan::New("ident").ToLocalChecked(), + Nan::New(Method)->GetFunction() ); }