ea5828bad54ad7aa0a91a4dced55afa4418b4c8d6c7ba54a4f50202a60f79152088e375ad24331714f5e0bdab11b6a1d9cf47083e27dc5fc7776f3645e7c5f 498 B

1234567891011121314151617
  1. import baseClamp from './_baseClamp.js';
  2. import copyArray from './_copyArray.js';
  3. import shuffleSelf from './_shuffleSelf.js';
  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. export default arraySampleSize;