(input: string)
| 123 | |
| 124 | // cyrb53's two 32-bit lanes, a 64-bit string hash |
| 125 | export const hashOf = (input: string): string => { |
| 126 | let h1 = 0xdeadbeef |
| 127 | let h2 = 0x41c6ce57 |
| 128 | for (let i = 0; i < input.length; i++) { |
| 129 | const code = input.charCodeAt(i) |
| 130 | h1 = Math.imul(h1 ^ code, 2654435761) |
| 131 | h2 = Math.imul(h2 ^ code, 1597334677) |
| 132 | } |
| 133 | h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) |
| 134 | h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909) |
| 135 | h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) |
| 136 | h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909) |
| 137 | return (h2 >>> 0).toString(36) + (h1 >>> 0).toString(36).padStart(7, "0") |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * How many insertions, deletions, substitutions and swaps of neighbors turn a |
no test coverage detected