File size: 413 Bytes
74411f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * Bayan — FNV-1a Hash (Single Implementation)
 *
 * 32-bit FNV-1a hash. Fast, zero dependencies.
 * Used for text deduplication in cache layers.
 *
 * @param {string} str
 * @returns {string} Base-36 hash string
 */
function bayanHash(str) {
  let h = 0x811c9dc5;
  for (let i = 0; i < str.length; i++) {
    h ^= str.charCodeAt(i);
    h = Math.imul(h, 0x01000193);
  }
  return (h >>> 0).toString(36);
}