f-utility
Version:
functional utilities
39 lines (35 loc) • 972 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.floorMin = exports.floor = undefined;
var _katsuCurry = require("katsu-curry");
/**
* Simple wrap for floor( x * random )
* @function random.floor
* @param {number} x - a number
* @return {number} x - a rounded number
* @public
* @example
* import {random} from 'f-utility'
* const {floor} = random
* floor(0) // 0
*/
var floor = exports.floor = function floor(x) {
return Math.floor(Math.random() * x);
};
/**
* Simple wrap for floor( x * random ) + min
* @function random.floorMin
* @param {number} min - a number to be the minimum
* @param {number} x - a number to be randomly rounded
* @return {number} a number that is randomly above the min
* @public
* @example
* import {random} from 'f-utility'
* const {floorMin} = random
* floor(0, 0) // 0
*/
var floorMin = exports.floorMin = (0, _katsuCurry.curry)(function (min, x) {
return floor(x) + min;
});
;