* Create a condition that checks if an element has one of the specified labels.
(labels: string[])
| 1960 | * Create a condition that checks if an element has one of the specified labels. |
| 1961 | */ |
| 1962 | function createLabelCondition(labels: string[]): StepCondition { |
| 1963 | if (labels.length === 0) { |
| 1964 | throw new Error("Cannot create label condition with empty labels array"); |
| 1965 | } |
| 1966 | |
| 1967 | if (labels.length === 1) { |
| 1968 | return ["=", "@label", labels[0]!] as StepCondition; |
| 1969 | } |
| 1970 | |
| 1971 | // Multiple labels - create OR condition |
| 1972 | const conditions = labels.map((label) => ["=", "@label", label] as StepCondition); |
| 1973 | |
| 1974 | return conditions.reduce((acc, condition) => { |
| 1975 | return ["or", acc, condition] as StepCondition; |
| 1976 | }); |
| 1977 | } |
| 1978 | |
| 1979 | /** |
| 1980 | * Convert a LabelExpression AST node to a StepCondition. |
no test coverage detected