lyvuha-portfolio / node_modules /lodash /_arraySample.js
Cong123779's picture
feat: add favicon, OG image, dual DB adapter (Supabase+SQLite), api utility
7c46a3a verified
Raw
History Blame Contribute Delete
363 Bytes
var baseRandom = require('./_baseRandom');
/**
* A specialized version of `_.sample` for arrays.
*
* @private
* @param {Array} array The array to sample.
* @returns {*} Returns the random element.
*/
function arraySample(array) {
var length = array.length;
return length ? array[baseRandom(0, length - 1)] : undefined;
}
module.exports = arraySample;