mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 05:33:44 +08:00
12 lines
290 B
JavaScript
12 lines
290 B
JavaScript
/*eslint no-bitwise:0 */
|
|
|
|
// Note: before changing this be aware the same algo is used server side for avatars.
|
|
export function hashString(str) {
|
|
let hash = 0;
|
|
for (let i = 0; i < str.length; i++) {
|
|
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
hash |= 0;
|
|
}
|
|
return hash;
|
|
}
|