Skip to content

Commit

Permalink
Merge pull request #1 from DuaneBrander/Ben_nan220
Browse files Browse the repository at this point in the history
Upgrading to Nan 2.2.0 for compatibility with newer versions of Node
  • Loading branch information
xero committed Apr 19, 2016
2 parents eeaaab5 + f293d71 commit c6a045d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -31,6 +31,6 @@
},
"dependencies": {
"bindings": "^1.2.1",
"nan": "^1.4.1"
"nan": "^2.2.0"
}
}
23 changes: 10 additions & 13 deletions src/objhash.cc
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
#include <nan.h>

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<Number>(hash));
void Method(const Nan::FunctionCallbackInfo<v8::Value>& 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<Object> exports) {
void Init(v8::Handle<v8::Object> exports) {
exports->Set(
NanNew("ident"),
NanNew<FunctionTemplate>(Ident)->GetFunction()
Nan::New("ident").ToLocalChecked(),
Nan::New<v8::FunctionTemplate>(Method)->GetFunction()
);
}

Expand Down

0 comments on commit c6a045d

Please sign in to comment.