Skip to content

Commit

Permalink
Make subscription fail safe with null channel names
Browse files Browse the repository at this point in the history
  • Loading branch information
jondubois committed Feb 2, 2020
1 parent 565a2a9 commit 41433a2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ const crypto = require('crypto');
function Hasher() {}

Hasher.prototype.hashToIndex = function (key, modulo) {
key = key || 0;
let ch;
let hash = key;

for (let i = 0; i < key.length; i++) {
ch = key.charCodeAt(i);
hash = ((hash << 5) - hash) + ch;
hash = hash & hash;
}
return Math.abs(hash || 0) % modulo;
return Math.abs(hash) % modulo;
};

Hasher.prototype.hashToHex = function (key, algorithm) {
Expand Down

0 comments on commit 41433a2

Please sign in to comment.