UNPKG

@technobuddha/library

Version:
18 lines (17 loc) 551 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.randomPick = void 0; /** * Pick a random items from a list. * * @param list Array of items to pick from * @param random Random number generator * @default random Math.random * @returns Randomly selected item */ function randomPick(list, random) { if (random === void 0) { random = Math.random; } return list.length === 0 ? undefined : list[Math.floor(random() * list.length)]; } exports.randomPick = randomPick; exports.default = randomPick;