You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
408 B
17 lines
408 B
"use strict"; |
|
|
|
function hash(str) { |
|
var hash = 5381, |
|
i = str.length; |
|
|
|
while(i) { |
|
hash = (hash * 33) ^ str.charCodeAt(--i); |
|
} |
|
|
|
/* JavaScript does bitwise operations (like XOR, above) on 32-bit signed |
|
* integers. Since we want the results to be always positive, convert the |
|
* signed int to an unsigned by doing an unsigned bitshift. */ |
|
return hash >>> 0; |
|
} |
|
|
|
module.exports = hash;
|
|
|