(n: number)
| 334 | while (n > 0xffffffff) { |
| 335 | h ^= n /= 0xffffffff |
| 336 | } |
| 337 | return optimize(h) |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * Computes a hash value for a string using the djb2 algorithm. |
| 342 | * |
| 343 | * **When to use** |
| 344 | * |
| 345 | * Use when you need a string field to contribute to a custom structural hash |
| 346 | * implementation. |
| 347 | * |
| 348 | * **Details** |
| 349 | * |
| 350 | * This function implements a variation of the djb2 hash algorithm, which is |
| 351 | * known for its good distribution properties and speed. It processes each |
| 352 | * character of the string to produce a consistent hash value. |
| 353 | * |
| 354 | * **Example** (Hashing strings) |
| 355 | * |
| 356 | * ```ts import.meta.vitest |
| 357 | * import { Hash } from "effect" |
no test coverage detected
searching dependent graphs…