Files
oneuptime/Common/Types/HashCode.ts

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;
}
}