项目原始demo,不改动
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

18 lines
500 B

  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;