MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / pickRandom

Method pickRandom

cosplay/cosplay.ts:261–273  ·  view source on GitHub ↗
(arr: T[], count: number)

Source from the content-addressed store, hash-verified

259 }
260
261 private pickRandom<T>(arr: T[], count: number): T[] {
262 if (count >= arr.length) return [...arr];
263 const result: T[] = [];
264 const used = new Set<number>();
265 while (result.length < count) {
266 const i = Math.floor(Math.random() * arr.length);
267 if (!used.has(i)) {
268 used.add(i);
269 result.push(arr[i]);
270 }
271 }
272 return result;
273 }
274}
275
276async function cleanup(files: string[]): Promise<void> {

Callers 1

fetchImageUrlsMethod · 0.95

Calls 1

addMethod · 0.45

Tested by

no test coverage detected