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

_arraySampleSize.js 500B

1234567891011121314151617
  1. var baseClamp = require('./_baseClamp'),
  2. copyArray = require('./_copyArray'),
  3. shuffleSelf = require('./_shuffleSelf');
  4. /**
  5. * A specialized version of `_.sampleSize` for arrays.
  6. *
  7. * @private
  8. * @param {Array} array The array to sample.
  9. * @param {number} n The number of elements to sample.
  10. * @returns {Array} Returns the random elements.
  11. */
  12. function arraySampleSize(array, n) {
  13. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  14. }
  15. module.exports = arraySampleSize;