UNPKG

@sapphire/utilities

Version:
18 lines (16 loc) 573 B
import { __name } from '../chunk-PAWJFY3S.mjs'; // src/lib/pickRandom.ts function pickRandom(array, amount = 1) { const arr = [...array]; if (typeof amount === "undefined" || amount === 1) { return arr[Math.floor(Math.random() * arr.length)]; } if (!arr.length || !amount) { return []; } return Array.from({ length: Math.min(amount, arr.length) }, () => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]); } __name(pickRandom, "pickRandom"); export { pickRandom }; //# sourceMappingURL=pickRandom.mjs.map //# sourceMappingURL=pickRandom.mjs.map