Skip to main content

CombinationsGenerator._generateRecursively() method

Recursively generates combinations as a generator, yielding one at a time.

Signature

protected _generateRecursively(index: number, combination: Record<string, string>): Generator<MatrixCombination>;

Parameters

Parameter

Type

Description

index

number

The current parameter index being processed.

combination

Record<string, string>

The partial combination being built.

Yields: Complete combinations one at a time.

Returns

Generator<MatrixCombination>

Remarks

This method implements the recursive algorithm for generating the Cartesian product of parameter values using the generator pattern.

Algorithm steps:

  1. Base case: If all parameters have been assigned values (index === matrixKeys.length), yield a copy of the current combination and return.
  2. Recursive case: For the parameter at the current index:
    • Iterate through all possible values for this parameter.
    • Assign each value to the combination object.
    • Recursively yield combinations for the next parameter using yield\*.
    • Remove the assigned value (backtrack) before trying the next value.

The combination object is reused and modified during traversal, with only copies of complete combinations being yielded. This approach minimises memory allocation whilst maintaining correctness.


Generated via tsdoc2docusaurus 1.3.2 by API Extractor/Documenter 7.57.2.