Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
m-akinc committed Mar 27, 2024
1 parent 37adef5 commit 3429e9c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/nimble-components/src/utilities/tests/matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const sharedMatrixParameters = () => ({
}) as const;

type MakeTupleEntriesArrays<T> = { [K in keyof T]: readonly T[K][] };

/**
* Calculates the cartesian product of an array of sets.
*/
Expand All @@ -50,23 +51,22 @@ export function cartesianProduct<T extends readonly unknown[]>(
}

/**
* Takes a template rendered with an array of states.
* Passes each of the given state combinations into a template function and returns the combined output.
*/
function createMatrixFromStates<T extends readonly unknown[]>(
component: (...states: T) => ViewTemplate,
states: T[]
): ViewTemplate {
const matrix = states.map(state => component(...state));
// prettier-ignore
return html`
${repeat(() => matrix, html`
${(x: ViewTemplate): ViewTemplate => x}
${repeat(() => states, html`
${(x: T): ViewTemplate => component(...x)}
`)}
`;
}

/**
* Takes a template rendered with the cartesian product the provided states.
* Creates a template that renders all combinations of states in the given dimensions.
*/
export function createMatrix<T extends readonly unknown[]>(
component: (...states: T) => ViewTemplate,
Expand Down

0 comments on commit 3429e9c

Please sign in to comment.