Closed ShynRou closed 5 years ago
Could you write me the exact arguments you have used and their types? Or better yet, make a gist with a complete erroneous example?
Ok, I've got it: murmurHash('foo','hex') 0
Thanks for reporting that.
However the behavior is correct. It's not an error. I will add a remark to the readme perhaps to clarify.
This is because the argument is encoding|output_type
The encoding has higher priority.
The possible encodings are: "ascii"|"base64"|"binary"|"hex"|"ucs-2"|"ucs2"|"utf-16le"|"utf-8"|"utf16le"|"utf8"
The possible output_types are: "base64"|"binary"|"buffer"|"hex"|"number"
.
So in case of encoding|output_type
the only output_type
recognized will be "buffer" and "number" because these are not valid encodings.
You can see them here in ts declarations.
murmurHash('foo', 'buffer')
<Buffer f6 a5 c4 20>
murmurHash('foo', 'number')
4138058784
murmurHash('foo', 'buffer',2)
<Buffer 20 8c 7f 62>
To fully disambiguate between encoding
and output_type
you need to put a seed
or encoding
argument prior to output_type
argument:
murmurHash('foo', 0, 'hex')
'f6a5c420'
murmurHash('foo', 'utf8', 'hex')
'f6a5c420'
Ah, okey. I would suggest reducing the complexity in the function overloading.
Hey,
I stumbled about an error: When trying to use the defined function header from the documentation
murmurHash(data{string}, encoding|output_type[, seed][, callback])
It won't work and return most of the time 0 But if you use the following and put the seed between the data and the encoding you get the right results.
murmurHash(data, seed, output_type[, callback])