MCPcopy Index your code
hub / github.com/TeaCoder52/patcode / pickRandom

Function pickRandom

src/utils.ts:15–19  ·  view source on GitHub ↗
(array: T[], rng: () => number)

Source from the content-addressed store, hash-verified

13}
14
15export function pickRandom<T>(array: T[], rng: () => number): T {
16 if (!array.length) throw new Error('Cannot pick from empty array')
17 const index = Math.floor(rng() * array.length)
18 return array[index]!
19}
20
21export function shuffle<T>(array: T[], rng: () => number): T[] {
22 const arr = array.slice()

Callers 1

pickDigitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected