Comparing version 1.0.0 to 1.0.1
@@ -13,3 +13,3 @@ 'use strict'; | ||
var HashRing = require('../') | ||
, Hash_ring = require('hash_ring') | ||
// , Hash_ring = require('hash_ring') | ||
, nodes = {'192.168.0.102:11212': 1, '192.168.0.103:11212': 1, '192.168.0.104:11212': 1}; | ||
@@ -25,4 +25,4 @@ | ||
*/ | ||
var ring1 = new HashRing(nodes) | ||
, ring2 = new Hash_ring(nodes); | ||
var ring1 = new HashRing(nodes); | ||
//, ring2 = new Hash_ring(nodes); | ||
@@ -36,4 +36,4 @@ /** | ||
var r = new HashRing(nodes); | ||
}).add('hash_ring', function(){ | ||
var r = new Hash_ring(nodes); | ||
//}).add('hash_ring', function(){ | ||
// var r = new Hash_ring(nodes); | ||
}).on('cycle', function cycle(e) { | ||
@@ -59,4 +59,4 @@ var details = e.target; | ||
ring1.get('key' + Math.random()); | ||
}).add('hash_ring', function(){ | ||
ring2.getNode('key' + Math.random()); | ||
//}).add('hash_ring', function(){ | ||
// ring2.getNode('key' + Math.random()); | ||
}).on('cycle', function cycle(e) { | ||
@@ -82,4 +82,4 @@ var details = e.target; | ||
ring1.get('key'); | ||
}).add('hash_ring', function(){ | ||
ring2.getNode('key'); | ||
//}).add('hash_ring', function(){ | ||
// ring2.getNode('key'); | ||
}).on('cycle', function cycle(e) { | ||
@@ -86,0 +86,0 @@ var details = e.target; |
10
index.js
@@ -195,3 +195,3 @@ 'use strict'; | ||
* @param {String} key | ||
* @returns {String} hash | ||
* @returns {String|Buffer} hash, depends on node version | ||
* @api private | ||
@@ -211,3 +211,9 @@ */ | ||
HashRing.prototype.digest = function digest(key) { | ||
return this.hash(key +'').toString().split('').map(function charCode(char) { | ||
var hash = this.hash(key +''); | ||
// Support for Node 0.10 which returns buffers so we don't need to charAt | ||
// lookups. | ||
if ('string' !== typeof hash) return hash; | ||
return hash.split('').map(function charCode(char) { | ||
return char.charCodeAt(0); | ||
@@ -214,0 +220,0 @@ }); |
{ | ||
"name": "hashring", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": "Arnout Kazemier", | ||
@@ -5,0 +5,0 @@ "description": "A consistent hashring compatible with ketama hashing and python's hash_ring", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1
2852053
888