• File: _arraySampleSize.js
  • Full Path: /var/www/nodejs/callDir/node_modules/lodash/_arraySampleSize.js
  • Date Modified: 06/03/2024 5:11 PM
  • File size: 500 bytes
  • MIME-type: text/plain
  • Charset: utf-8
var baseClamp = require('./_baseClamp'),
    copyArray = require('./_copyArray'),
    shuffleSelf = require('./_shuffleSelf');

/**
 * A specialized version of `_.sampleSize` for arrays.
 *
 * @private
 * @param {Array} array The array to sample.
 * @param {number} n The number of elements to sample.
 * @returns {Array} Returns the random elements.
 */
function arraySampleSize(array, n) {
  return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
}

module.exports = arraySampleSize;