16 lines
274 B
JavaScript
16 lines
274 B
JavaScript
|
function hash (str) {
|
||
|
var i = str.length
|
||
|
var hash1 = 5381
|
||
|
var hash2 = 52711
|
||
|
|
||
|
while (i--) {
|
||
|
const char = str.charCodeAt(i)
|
||
|
hash1 = (hash1 * 33) ^ char
|
||
|
hash2 = (hash2 * 33) ^ char
|
||
|
}
|
||
|
|
||
|
return (hash1 >>> 0) * 4096 + (hash2 >>> 0)
|
||
|
}
|
||
|
|
||
|
module.exports = hash
|