diff --git a/mhash.cc b/mhash.cc index f1daa8d..6f31f0f 100644 --- a/mhash.cc +++ b/mhash.cc @@ -126,39 +126,44 @@ hashid get_hash_type_by_name(char * name) NAN_METHOD(Hash) { - NanScope(); Local ret; char * hashed=0; hashid type; - String::Utf8Value name(args[0]->ToString()); + String::Utf8Value name(info[0]->ToString()); type = get_hash_type_by_name(*name); if(type==(hashid)-1) - NanReturnValue(NanNull()); + { + info.GetReturnValue().Set(Nan::Null()); + return; + } - if(args[1]->IsString()) + if(info[1]->IsString()) { - String::Utf8Value data(args[1]->ToString()); + String::Utf8Value data(info[1]->ToString()); hashed = hash(type, (unsigned char *)*data, data.length()); } - else if(node::Buffer::HasInstance(args[1])) + else if(node::Buffer::HasInstance(info[1])) { - Handle data = args[1]->ToObject(); + Handle data = info[1]->ToObject(); hashed = hash(type, (unsigned char *)node::Buffer::Data(data), node::Buffer::Length(data)); } if(!hashed) - NanReturnValue(NanNull()); + { + info.GetReturnValue().Set(Nan::Null()); + return; + } - ret = NanNew(hashed); + ret = Nan::New(hashed).ToLocalChecked(); free(hashed); - NanReturnValue(ret); + info.GetReturnValue().Set(ret); } void Init(Handle exports) { - exports->Set(NanNew("hash"), NanNew(Hash)->GetFunction()); + exports->Set(Nan::New("hash").ToLocalChecked(), Nan::New(Hash)->GetFunction()); } NODE_MODULE(mhash, Init) diff --git a/package.json b/package.json index b70e072..56afffa 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "mhash", - "version": "2.0.2", + "version": "2.1.0", "author": "Robert Schultz ", "description": "Provides 27 hashing algorithms: md5, md4, md2, sha1, sha256, whirlpool, crc32, etc. MacOS X requires Xcode to be installed.", "main": "index", - "dependencies" : { "bindings" : "= 1.2.1", "nan" : "= 1.9.0" }, + "dependencies" : { "bindings" : "= 1.2.1", "nan" : "= 2.0.7" }, "engines": { "node": ">= 0.8.0" }, "keywords": [ "hash", "md5", "sha", "crc", "whirlpool", "haval", "ripemd", "gost", "snefru", "alder", "tiger", "crc32", "crc32b", "sha256", "md4", "md2" ], "homepage" : "http://github.com/Sembiance/mhash",