murmurhash3
Advanced tools
Comparing version 0.2.4 to 0.2.5
# Revision history for murmurhash3 | ||
0.2.5 / 2014-04-23 | ||
================== | ||
* Node.js v0.11 support (v0.12 ready) | ||
* Refactoring | ||
* Improve test | ||
* Update document | ||
0.2.4 / 2014-04-23 | ||
@@ -4,0 +12,0 @@ ================== |
@@ -11,3 +11,3 @@ /*! | ||
exports.version = '0.2.4'; | ||
exports.version = '0.2.5'; | ||
@@ -21,10 +21,12 @@ var binding; | ||
var E_CALLBACK_MISSING = "Callback function is missing"; | ||
//Aync interface | ||
exports.murmur32 = function(key, seed, cb) { | ||
if ( typeof seed == 'function' ) { | ||
cb = seed; | ||
if ( typeof seed == 'function') { | ||
cb = seed; | ||
seed = 0; | ||
} | ||
if( cb === undefined || typeof cb != 'function' ){ | ||
throw new Error("Callback function missing"); | ||
if (cb === undefined || typeof cb != 'function') { | ||
throw new Error(E_CALLBACK_MISSING); | ||
} | ||
@@ -42,2 +44,5 @@ var res = binding.murmur32(key, seed, false, function(err, res) { | ||
} | ||
if (cb === undefined || typeof cb != 'function') { | ||
throw new Error(E_CALLBACK_MISSING); | ||
} | ||
return binding.murmur32(key, seed, true, cb); | ||
@@ -50,4 +55,4 @@ }; | ||
} | ||
if( cb === undefined || typeof cb != 'function' ){ | ||
throw new Error("Callback function missing"); | ||
if (cb === undefined || typeof cb != 'function') { | ||
throw new Error(E_CALLBACK_MISSING); | ||
} | ||
@@ -67,2 +72,5 @@ binding.murmur128(key, seed, false, function(err, res) { | ||
} | ||
if (cb === undefined || typeof cb != 'function') { | ||
throw new Error(E_CALLBACK_MISSING); | ||
} | ||
return binding.murmur128(key, seed, true, cb); | ||
@@ -69,0 +77,0 @@ }; |
{ | ||
"name": "murmurhash3", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "Node binding of MurmurHash3", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/hideo55/node-murmurhash3", |
@@ -24,3 +24,3 @@ # murmurhash3 | ||
You must use murmurhash3 0.2.4 or later. | ||
You must use murmurhash3 0.2.5 or later. | ||
It is strongly recommended to use latest version. | ||
@@ -27,0 +27,0 @@ |
91
test.js
@@ -143,3 +143,4 @@ var mmh3 = require('./lib/murmurhash3'); | ||
try { | ||
mmh3.murmur32(undefined, function(){}); | ||
mmh3.murmur32(undefined, function() { | ||
}); | ||
} catch(e) { | ||
@@ -153,3 +154,4 @@ if ((new RegExp(/^Argument 0 must be a String/)).test(e.message)) { | ||
try { | ||
mmh3.murmur32('key', -1, function(){}); | ||
mmh3.murmur32('key', -1, function() { | ||
}); | ||
} catch(e) { | ||
@@ -161,7 +163,45 @@ if ((new RegExp(/^Argument 1 must be a Uint32/)).test(e.message)) { | ||
}); | ||
it('callback missing', function(done) { | ||
try { | ||
mmh3.murmur32('key', 0); | ||
} catch(e) { | ||
if ((new RegExp(/^Callback function is missing/)).test(e.message)) { | ||
done(); | ||
} | ||
} | ||
}); | ||
it('not function', function(done) { | ||
try { | ||
mmh3.murmur32('key', 0, 0); | ||
} catch(e) { | ||
if ((new RegExp(/^Callback function is missing/)).test(e.message)) { | ||
done(); | ||
} | ||
} | ||
}); | ||
it('callback missing - hex', function(done) { | ||
try { | ||
mmh3.murmur32Hex('key', 0); | ||
} catch(e) { | ||
if ((new RegExp(/^Callback function is missing/)).test(e.message)) { | ||
done(); | ||
} | ||
} | ||
}); | ||
it('not function - hex', function(done) { | ||
try { | ||
mmh3.murmur32Hex('key', 0, 0); | ||
} catch(e) { | ||
if ((new RegExp(/^Callback function is missing/)).test(e.message)) { | ||
done(); | ||
} | ||
} | ||
}); | ||
}); | ||
describe('murmur128', function() { | ||
it('key must be string', function(done) { | ||
try { | ||
mmh3.murmur128(undefined, function(){}); | ||
mmh3.murmur128(undefined, function() { | ||
}); | ||
} catch(e) { | ||
@@ -175,3 +215,4 @@ if ((new RegExp(/^Argument 0 must be a String/)).test(e.message)) { | ||
try { | ||
mmh3.murmur128('key', -1, function() {}); | ||
mmh3.murmur128('key', -1, function() { | ||
}); | ||
} catch(e) { | ||
@@ -183,3 +224,40 @@ if ((new RegExp(/^Argument 1 must be a Uint32/)).test(e.message)) { | ||
}); | ||
}); | ||
it('callback missing', function(done) { | ||
try { | ||
mmh3.murmur128('key', 0); | ||
} catch(e) { | ||
if ((new RegExp(/^Callback function is missing/)).test(e.message)) { | ||
done(); | ||
} | ||
} | ||
}); | ||
it('not function', function(done) { | ||
try { | ||
mmh3.murmur128('key', 0, 0); | ||
} catch(e) { | ||
if ((new RegExp(/^Callback function is missing/)).test(e.message)) { | ||
done(); | ||
} | ||
} | ||
}); | ||
it('callback missing - hex', function(done) { | ||
try { | ||
mmh3.murmur128Hex('key', 0); | ||
} catch(e) { | ||
if ((new RegExp(/^Callback function is missing/)).test(e.message)) { | ||
done(); | ||
} | ||
} | ||
}); | ||
it('not function - hex', function(done) { | ||
try { | ||
mmh3.murmur128Hex('key', 0, 0); | ||
} catch(e) { | ||
if ((new RegExp(/^Callback function is missing/)).test(e.message)) { | ||
done(); | ||
} | ||
} | ||
}); | ||
}); | ||
describe('murmur32Sync', function() { | ||
@@ -205,2 +283,3 @@ it('key must be string', function(done) { | ||
}); | ||
describe('murmur128Sync', function() { | ||
@@ -225,4 +304,4 @@ it('key must be string', function(done) { | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
34680
393