UNPKG

swingset

Version:

drop-in component library and documentation pages for next.js

11 lines (10 loc) 256 B
export default function simpleHash(str: string) { let hash = 0 if (str.length == 0) return hash for (let i = 0; i < str.length; i++) { const char = str.charCodeAt(i) hash = (hash << 5) - hash + char hash = hash & hash } return hash }