diff --git a/M01_MasterData/LogicBuilder/M01_LB_Check.ts b/M01_MasterData/LogicBuilder/M01_LB_Check.ts index 075c8a9f4..95d28fc75 100644 --- a/M01_MasterData/LogicBuilder/M01_LB_Check.ts +++ b/M01_MasterData/LogicBuilder/M01_LB_Check.ts @@ -12,7 +12,7 @@ * ========================================================================== */ import type { CalcAnswer, LogicRow } from "../M01_MasterData_UI_Logic_Api"; -import { lbCalcLater, type LbTables } from "./M01_LB_Api"; +import { lbCalcNow, type LbTables } from "./M01_LB_Api"; import { writeLogic, type LbLogic, type LbLookup } from "./M01_LB_Blocks"; type Cell = string | number | boolean | null | [number | null, number | null]; @@ -212,20 +212,20 @@ type CalcFn = ( tables: LbTables, ) => Promise; -/** LB Api 계산을 한 번 기다림 — 차례로 부르므로 「최신만」 에 안 걸림 */ -const calcOnce: CalcFn = (row, inputs, tables) => - new Promise((resolve, reject) => - lbCalcLater(row, inputs, tables, (ans, plain) => - ans ? resolve(ans) : reject(new Error(plain ?? "")), - ), - ); +/** LB Api 바로 계산 — 화면 예시값 계산(0.3초 · 최신만)과 안 부딪힘 · 멈춤 까닭은 쉬운 말로 */ +const calcNow: CalcFn = async (row, inputs, tables) => { + let plain = ""; + const ans = await lbCalcNow(row, inputs, tables, (p) => (plain = p)); + if (!ans) throw new Error(plain); + return ans.ok ? ans : { ok: false, reason: plain || ans.reason }; +}; /** 줄마다 시험 계산(차례로 · 하나씩) — 로직은 블록을 글로 되돌린 줄 · `calc` 는 시험에서 바꿔 끼움 */ export async function runExpect( lb: LbLogic, tables: LbTables, rows: ExpectRow[], - calc: CalcFn = calcOnce, + calc: CalcFn = calcNow, ): Promise { const row = writeLogic(lb); const out: ExpectResult[] = [];