Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_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;