_baseSample.js 359 B

12345678910111213141516
  1. var arraySample = require('./_arraySample'),
  2. values = require('./values');
  3. /**
  4. * The base implementation of `_.sample`.
  5. *
  6. * @private
  7. * @param {Array|Object} collection The collection to sample.
  8. * @returns {*} Returns the random element.
  9. */
  10. function baseSample(collection) {
  11. return arraySample(values(collection));
  12. }
  13. module.exports = baseSample;