From de53faa82864475d95f883d4234acf472ea60f6e Mon Sep 17 00:00:00 2001 From: itsMapleLeaf <19603573+itsMapleLeaf@users.noreply.github.com> Date: Wed, 27 Jul 2022 12:47:17 -0500 Subject: [PATCH] move generate prop combinations to helpers --- .../reacord/scripts/discordjs-manual-test.tsx | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/packages/reacord/scripts/discordjs-manual-test.tsx b/packages/reacord/scripts/discordjs-manual-test.tsx index 064f7a6..ef47d1f 100644 --- a/packages/reacord/scripts/discordjs-manual-test.tsx +++ b/packages/reacord/scripts/discordjs-manual-test.tsx @@ -4,6 +4,7 @@ import "dotenv/config" import { chunk, kebabCase } from "lodash-es" import prettyMilliseconds from "pretty-ms" import React, { useEffect, useState } from "react" +import { generatePropCombinations } from "../helpers/generate-prop-combinations" import { raise } from "../helpers/raise" import { waitFor } from "../helpers/wait-for" import type { ButtonProps } from "../library.new/main" @@ -154,25 +155,3 @@ await createTest( instance.destroy() }, ) - -function generatePropCombinations

(values: { - [K in keyof P]: ReadonlyArray -}) { - return generatePropCombinationsRecursive(values) as P[] -} - -function generatePropCombinationsRecursive( - value: Record, -): Array> { - const [key] = Object.keys(value) - if (!key) return [{}] - - const { [key]: values = [], ...otherValues } = value - const result: Array> = [] - for (const value of values) { - for (const otherValue of generatePropCombinationsRecursive(otherValues)) { - result.push({ [key]: value, ...otherValue }) - } - } - return result -}