UNPKG

@prelude/array

Version:

Array module.

12 lines (9 loc) 213 B
import randomIndex from './random-index.js' /** * @returns random element. * @throws if array is empty. */ const sample = <T>(values: T[]): T => values[randomIndex(values.length)] export default sample