All files / client/src/lib io-registry-state.ts

100% Statements 2/2
100% Branches 6/6
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21                            10x   10x        
import type { IOPinRecord } from "@shared/schema";
import type { SimulationStatus } from "@shared/types/arduino.types";
 
/**
 * Runtime snapshots are authoritative while a simulation is running (or
 * paused). Before the first runtime snapshot, and after the run has ended,
 * the current static analysis remains visible.
 */
export function getEffectiveIoRegistry(
  staticIoRegistry: IOPinRecord[],
  runtimeIoRegistry: IOPinRecord[] | null,
  simulationStatus: SimulationStatus,
): IOPinRecord[] {
  const simulationActive =
    simulationStatus === "running" || simulationStatus === "paused";
 
  return simulationActive && runtimeIoRegistry !== null
    ? runtimeIoRegistry
    : staticIoRegistry;
}