![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/local/lib/node_modules/random-number/ |
Upload File : |
void function(root){ function defaults(options){ var options = options || {} var min = options.min var max = options.max var integer = options.integer || false if ( min == null && max == null ) { min = 0 max = 1 } else if ( min == null ) { min = max - 1 } else if ( max == null ) { max = min + 1 } if ( max < min ) throw new Error('invalid options, max must be >= min') return { min: min , max: max , integer: integer } } function random(options){ options = defaults(options) if ( options.max === options.min ) return options.min var r = Math.random() * (options.max - options.min + Number(!!options.integer)) + options.min return options.integer ? Math.floor(r) : r } function generator(options){ options = defaults(options) return function(min, max, integer){ options.min = min != null ? min : options.min options.max = max != null ? max : options.max options.integer = integer != null ? integer : options.integer return random(options) } } module.exports = random module.exports.generator = generator module.exports.defaults = defaults }(this)