import { Random } from 'random' export type Sampler = (objects: T[]) => T | undefined export function getSampler(random: Random): Sampler { return (array: T[]) => { const index = random.int(0, array.length - 1) return array.length ? array[index] : undefined } }