MCPcopy Create free account
hub / github.com/ethanniser/NextFaster / getRandomObjects

Function getRandomObjects

scripts/fill.ts:19–34  ·  view source on GitHub ↗
(arr: any[], count: number)

Source from the content-addressed store, hash-verified

17};
18
19function getRandomObjects(arr: any[], count: number) {
20 const result = [];
21 const takenIndices = new Set();
22 const arrLength = arr.length;
23
24 while (result.length < count) {
25 const randomIndex = Math.floor(Math.random() * arrLength);
26
27 if (!takenIndices.has(randomIndex)) {
28 result.push(arr[randomIndex]);
29 takenIndices.add(randomIndex);
30 }
31 }
32
33 return result;
34}
35
36const getBody = async () => {
37 const fileStream = fs.createReadStream("scripts/out.jsonl");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected