MCPcopy Create free account
hub / github.com/codeaashu/claude-code / hashString

Function hashString

src/buddy/companion.ts:27–37  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

25}
26
27function hashString(s: string): number {
28 if (typeof Bun !== 'undefined') {
29 return Number(BigInt(Bun.hash(s)) & 0xffffffffn)
30 }
31 let h = 2166136261
32 for (let i = 0; i < s.length; i++) {
33 h ^= s.charCodeAt(i)
34 h = Math.imul(h, 16777619)
35 }
36 return h >>> 0
37}
38
39function pick<T>(rng: () => number, arr: readonly T[]): T {
40 return arr[Math.floor(rng() * arr.length)]!

Callers 2

rollFunction · 0.70
rollWithSeedFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected