MCPcopy Create free account
hub / github.com/codemix/graph / createLabelCondition

Function createLabelCondition

packages/graph/src/astToSteps.ts:1962–1977  ·  view source on GitHub ↗

* Create a condition that checks if an element has one of the specified labels.

(labels: string[])

Source from the content-addressed store, hash-verified

1960 * Create a condition that checks if an element has one of the specified labels.
1961 */
1962function 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.

Callers 1

createNodeLabelConditionFunction · 0.85

Calls 1

mapMethod · 0.45

Tested by

no test coverage detected