arvo-event-handler
Version:
A complete set of orthogonal event handler and orchestration primitives for Arvo based applications, featuring declarative state machines (XState), imperative resumables for agentic workflows, contract-based routing, OpenTelemetry observability, and in-me
29 lines (28 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.detectParallelStates = void 0;
/**
* Detects if an XState machine configuration contains any parallel states.
* Uses a stack-based approach for efficient traversal of the state hierarchy.
* @param config - XState machine configuration
* @returns True if the machine contains at least one parallel state, false otherwise
*/
var detectParallelStates = function (config) {
if (!(config === null || config === void 0 ? void 0 : config.states)) {
return false;
}
var stack = [config];
while (stack.length) {
var currentConfig = stack.pop();
if (!(currentConfig === null || currentConfig === void 0 ? void 0 : currentConfig.states))
continue;
if (currentConfig.type === 'parallel')
return true;
for (var _i = 0, _a = Object.values(currentConfig.states); _i < _a.length; _i++) {
var state = _a[_i];
stack.push(state);
}
}
return false;
};
exports.detectParallelStates = detectParallelStates;