(values: T[], minCount: number, maxCount: number)
| 226 | } |
| 227 | |
| 228 | function sampleMany<T>(values: T[], minCount: number, maxCount: number): T[] { |
| 229 | const count = randomInt(minCount, Math.min(maxCount, values.length)); |
| 230 | const shuffled = [...values]; |
| 231 | for (let i = shuffled.length - 1; i > 0; i -= 1) { |
| 232 | const j = randomInt(0, i); |
| 233 | [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]]; |
| 234 | } |
| 235 | return shuffled.slice(0, count); |
| 236 | } |
| 237 | |
| 238 | function hslToHex(hue: number, saturation: number, lightness: number): string { |
| 239 | const s = saturation / 100; |
no test coverage detected