UNPKG

delta-component

Version:

embeddable react component

12 lines (11 loc) 329 B
export function generateSiteId(str: string): number { let hash = 0; let chr; if (str.length === 0) return hash; for (let i = 0; i < str .length; i++) { chr = str.charCodeAt(i); hash = ((hash << 5) - hash) + chr; hash |= 0; // Convert to 32bit integer } return Math.abs(hash); }