Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add buffer support for hash128/crc128/crc256

  • Loading branch information...
commit cab59a3d393c67e750a3ea30ea5706e4df440bfe 1 parent 9d25247
@yyfrankyy yyfrankyy authored
Showing with 18 additions and 0 deletions.
  1. +18 −0 binding.cc
  2. 0  package.json
View
18 binding.cc
@@ -273,6 +273,12 @@ node_CityHash128(const Arguments& args) {
const char* str = *data;
size_t len = data.length();
+ if (Buffer::HasInstance(args[0])) {
+ Local<Object> obj = args[0]->ToObject();
+ str = Buffer::Data(obj);
+ len = Buffer::Length(obj);
+ }
+
uint128 hash;
if(args.Length() == 2) {
@@ -301,6 +307,12 @@ node_CityHashCrc128(const Arguments& args) {
const char* str = *data;
size_t len = data.length();
+ if (Buffer::HasInstance(args[0])) {
+ Local<Object> obj = args[0]->ToObject();
+ str = Buffer::Data(obj);
+ len = Buffer::Length(obj);
+ }
+
uint128 hash;
if(args.Length() == 2) {
@@ -338,6 +350,12 @@ node_CityHashCrc256(const Arguments& args) {
const char* str = *data;
size_t len = data.length();
+ if (Buffer::HasInstance(args[0])) {
+ Local<Object> obj = args[0]->ToObject();
+ str = Buffer::Data(obj);
+ len = Buffer::Length(obj);
+ }
+
if(CityHashCrc256 == NULL) {
return ThrowException(String::New("CityHashCrc256 function does not found."));
}
View
0  package.json 100755 → 100644
File mode changed
Please sign in to comment.
Something went wrong with that request. Please try again.