Files
NapCatQQ/.pnpm-store/v3/files/ad/8779513b51cff78d993b86a333a7e77ca6db4c4b0a11f9995a92b55eb538f7c68adb561bae5be156b5105bae3c1f95c2b18bed64796d8928f3cf40a2fe4e58
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

25 lines
549 B
Plaintext

import arraySample from './_arraySample.js';
import baseSample from './_baseSample.js';
import isArray from './isArray.js';
/**
* 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);
}
export default sample;