* Simple deterministic hash function that produces an 8-character hex string. * Uses a variant of djb2 hash algorithm.
(str: string)
| 238 | * Uses a variant of djb2 hash algorithm. |
| 239 | */ |
| 240 | function simpleHash(str: string): string { |
| 241 | let hash = 5381 |
| 242 | for (let i = 0; i < str.length; i++) { |
| 243 | hash = (hash << 5) + hash + str.charCodeAt(i) |
| 244 | hash = hash >>> 0 |
| 245 | } |
| 246 | return hash.toString(16).padStart(8, '0').slice(0, 8) |
| 247 | } |
no test coverage detected