docs(helpers): explain djb2 seed constant in stringHash
This commit is contained in:
parent
65b6e55252
commit
4b3b5bb87c
|
|
@ -1,6 +1,8 @@
|
|||
// Deterministic non-cryptographic string hash (djb2 variant).
|
||||
// Used for stable pseudo-random selection keyed on date + user + bucket.
|
||||
export function stringHash(input: string): number {
|
||||
// 5381 is the canonical djb2 seed — a prime that empirically yields a good
|
||||
// distribution when combined with the `hash * 33 + c` step below.
|
||||
let hash = 5381
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
// hash * 33 + char, kept in 32-bit range via `| 0`.
|
||||
|
|
|
|||
Loading…
Reference in New Issue