fixed hash shit

This commit is contained in:
MasterGordon 2024-10-18 18:12:18 +02:00
parent d1c7d4d0da
commit 0dca37f035
1 changed files with 0 additions and 15 deletions

View File

@ -3,21 +3,6 @@ export const pickRandom = <T>(arr: T[]) => {
return arr[index];
};
function bashHashStr(str: string) {
let hash = 5381,
i = str.length;
while (i) {
hash = (hash * 33) ^ str.charCodeAt(--i);
}
return hash >>> 0;
}
export const hashStr = (str: string) => {
return Number(`0.${bashHashStr(str)}`);
};
export const weightedPickRandom = <T>(
arr: T[],
getWeight: (item: T) => number = () => 1,