vtils
Version:
一个面向业务的 JavaScript/TypeScript 实用程序库。
15 lines (13 loc) • 387 B
JavaScript
exports.__esModule = true;
exports.sampleIndex = sampleIndex;
var _lodashUni = require("lodash-uni");
var _sampleBy = require("./sampleBy");
/**
* 从集合中随机获得一个元素的索引(数组)或键(对象)。
*
* @param collection 集合
*/
function sampleIndex(collection) {
return (0, _sampleBy.sampleBy)(collection, (0, _lodashUni.nthArg)(1));
}
;