Create random.js

This commit is contained in:
Namhyeon Go 2022-01-09 01:42:00 +09:00 committed by GitHub
parent f4fbd2ad1c
commit ea20382f62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

16
lib/random.js Normal file
View File

@ -0,0 +1,16 @@
function getInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function one(arr) {
return arr[range(0, arr.length - 1)];
}
exports.getInt = getInt;
exports.one = one;
exports.VERSIONINFO = "Random Module (random.js) version 0.1";
exports.global = global;
exports.require = global.require;