summaryrefslogtreecommitdiff
path: root/source/helpers/hash-string.ts
blob: adc49c48a58cc1c8cc7e1efa6949bb59438495d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
export default function hashString(string: string): string {
	let hash = 0;

	for (const character of string) {
		// eslint-disable-next-line no-bitwise
		hash = ((hash << 5) - hash) + character.codePointAt(0)!;
	}

	return String(Math.trunc(hash));
}