Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

_baseSampleSize.js 548B

123456789101112131415161718
  1. var baseClamp = require('./_baseClamp'),
  2. shuffleSelf = require('./_shuffleSelf'),
  3. values = require('./values');
  4. /**
  5. * The base implementation of `_.sampleSize` without param guards.
  6. *
  7. * @private
  8. * @param {Array|Object} collection The collection to sample.
  9. * @param {number} n The number of elements to sample.
  10. * @returns {Array} Returns the random elements.
  11. */
  12. function baseSampleSize(collection, n) {
  13. var array = values(collection);
  14. return shuffleSelf(array, baseClamp(n, 0, array.length));
  15. }
  16. module.exports = baseSampleSize;