UNPKG

@prelude/array

Version:

Array module.

8 lines 279 B
const randomIndex = (length) => { if (length < 1) { throw new TypeError(`Can't get random index for length ${length}.`); } return Math.min(length - 1, Math.floor(Math.random() * length)); }; export default randomIndex; //# sourceMappingURL=random-index.js.map