20 lines
435 B
TypeScript
20 lines
435 B
TypeScript
export function countWorkflowOperators(
|
|
nodes?: Array<{ type?: string; data?: Record<string, unknown> } | null>,
|
|
): number {
|
|
if (!Array.isArray(nodes)) {
|
|
return 0;
|
|
}
|
|
|
|
return nodes.filter((node) => {
|
|
if (!node || typeof node !== "object") {
|
|
return false;
|
|
}
|
|
|
|
if (node.type === "operator") {
|
|
return true;
|
|
}
|
|
|
|
return typeof node.type !== "string" && typeof node.data === "object";
|
|
}).length;
|
|
}
|