UNPKG

@lazy-random/util-distributions

Version:
37 lines (31 loc) 1.12 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LazyRandomUtilDistributions = {})); })(this, (function (exports) { 'use strict'; function randIndex(random, len) { return Math.floor(random.next() * len); } function randIndexWithRange(random, start, end) { return Math.floor(float(random, start, end)); } function float(random, min, max) { return random.next() * (max - min) + min; } function int(random, min, max) { //return Math.floor(float(random, min, max + 1)) return randIndexWithRange(random, min, max + 1); } const UtilDistributions = { randIndex, float, int }; exports.default = UtilDistributions; exports.float = float; exports.int = int; exports.randIndex = randIndex; exports.randIndexWithRange = randIndexWithRange; Object.defineProperty(exports, '__esModule', { value: true }); })); //# sourceMappingURL=index.umd.development.cjs.map