(s: string)
| 25 | } |
| 26 | |
| 27 | function 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 | |
| 39 | function pick<T>(rng: () => number, arr: readonly T[]): T { |
| 40 | return arr[Math.floor(rng() * arr.length)]! |
no outgoing calls
no test coverage detected