mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
12 lines
331 B
TypeScript
12 lines
331 B
TypeScript
export default class HashCode {
|
|
public static fromString(text: string): number {
|
|
let hash: number = 0;
|
|
for (let i: number = 0; i < text.length; i++) {
|
|
const code: number = text.charCodeAt(i);
|
|
hash = (hash << 5) - hash + code;
|
|
hash = hash & hash; // Convert to 32bit integer
|
|
}
|
|
return hash;
|
|
}
|
|
}
|