DocsCommonutilitiesGenerateAllCombinations
Package: @hexos/common

Computes the Cartesian product of multiple option groups, returning all possible combinations.

Takes an array of arrays (option groups) and produces every combination by selecting one element from each group. Empty groups are filtered out before processing. Uses recursive accumulation to build combinations.

Example

generateAllCombinations([['red', 'blue'], ['small', 'large']]);
// => [['red', 'small'], ['red', 'large'], ['blue', 'small'], ['blue', 'large']]
function generateAllCombinations<T>(optionGroups: T[][], combination: T[] = [], k: number = 0, output: T[][] = []): T[][]

Parameters

optionGroups

T[][]

combination

T[]

k

number

output

T[][]