Urara-Blog/node_modules/.pnpm-store/v3/files/a2/8ebf6e887befa6635c26fe0c5666082a1203b0ee817b789c05028d261ce3b29a209ed7d95e2134654ce080a4c6d808b555cfbcbcaae6ce5161d37c538b627f
2022-08-14 01:14:53 +08:00

24 lines
551 B
Text

var arraySample = require('./_arraySample'),
baseSample = require('./_baseSample'),
isArray = require('./isArray');
/**
* Gets a random element from `collection`.
*
* @static
* @memberOf _
* @since 2.0.0
* @category Collection
* @param {Array|Object} collection The collection to sample.
* @returns {*} Returns the random element.
* @example
*
* _.sample([1, 2, 3, 4]);
* // => 2
*/
function sample(collection) {
var func = isArray(collection) ? arraySample : baseSample;
return func(collection);
}
module.exports = sample;