import { randomInt } from 'crypto'; const ri: (args1: number) => Promise = (await import('util')).promisify( randomInt ); export function choice(array: T[]): T { return array[Math.floor(Math.random() * array.length)]; } export function secureChoiceSync(array: T[]): T { return array[randomInt(array.length)]; } export async function secureChoice(array: T[]): Promise { return array[await ri(array.length)]; }