Method
pickRandom
(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 | |
| 276 | async function cleanup(files: string[]): Promise<void> { |
Tested by
no test coverage detected