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() ); }