schat2-clive/src/utils/pick-random.js

14 lines
207 B
JavaScript
Executable File

'use strict';
const crypto = require('crypto');
function pickRandom(array) {
if (array.length === 0) {
return null;
}
return array[crypto.randomInt(0, array.length)];
}
module.exports = pickRandom;