Files
lodash/.internal/baseSampleSize.js
John-David Dalton aa60e55db4 Update module paths.
2017-01-11 10:06:12 -08:00

19 lines
545 B
JavaScript

import baseClamp from './baseClamp.js';
import shuffleSelf from './shuffleSelf.js';
import values from '../values.js';
/**
* The base implementation of `sampleSize` without param guards.
*
* @private
* @param {Array|Object} collection The collection to sample.
* @param {number} n The number of elements to sample.
* @returns {Array} Returns the random elements.
*/
function baseSampleSize(collection, n) {
const array = values(collection);
return shuffleSelf(array, baseClamp(n, 0, array.length));
}
export default baseSampleSize;