UNPKG

f-utility

Version:

functional utilities

21 lines (20 loc) 521 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Simple wrap for round( x * random ) * @function random * @param {number} x - a number * @return {number} x - a rounded and randomized number * @public * @example * import {random} from 'f-utility' * random(5) // 1 * random(5) // 3 * random(0) // 0 */ var random = exports.random = function random() { var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; return Math.round(Math.random() * x); };