You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 regels
363 B

3 jaren geleden
  1. var baseRandom = require('./_baseRandom');
  2. /**
  3. * A specialized version of `_.sample` for arrays.
  4. *
  5. * @private
  6. * @param {Array} array The array to sample.
  7. * @returns {*} Returns the random element.
  8. */
  9. function arraySample(array) {
  10. var length = array.length;
  11. return length ? array[baseRandom(0, length - 1)] : undefined;
  12. }
  13. module.exports = arraySample;