MCPcopy Create free account
hub / github.com/VienLi/CcView / getRandomItem

Function getRandomItem

src/utils/common.ts:28–31  ·  view source on GitHub ↗
(arr: any[], index?: number)

Source from the content-addressed store, hash-verified

26
27// 获取数组中随机元素
28export function getRandomItem(arr: any[], index?: number) {
29 index || (index = Math.round(Math.random() * (arr.length - 1)));
30 return arr[index];
31}
32
33export function getStorage(key: string, defaultValue: any) {
34 if (typeof window !== 'undefined') {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected