Files
lodash/.internal/baseSampleSize.js
John-David Dalton 6cb3460fce Remove semicolons.
2017-02-05 22:22:04 -08:00

19 lines
539 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