UNPKG

@prelude/array

Version:

Array module.

10 lines 359 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); 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)); }; exports.default = randomIndex; //# sourceMappingURL=random-index.js.map