MCPcopy Create free account
hub / github.com/bergside/typeui / sampleMany

Function sampleMany

src/generation/randomDesignSystem.ts:228–236  ·  view source on GitHub ↗
(values: T[], minCount: number, maxCount: number)

Source from the content-addressed store, hash-verified

226}
227
228function 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
238function hslToHex(hue: number, saturation: number, lightness: number): string {
239 const s = saturation / 100;

Callers 3

generateTypographyScaleFunction · 0.85
generateColorPaletteFunction · 0.85

Calls 1

randomIntFunction · 0.85

Tested by

no test coverage detected