Files
Aislo/resources/tester/helper_850_2_basis.cjs
T

25 lines
1.2 KiB
JavaScript

/* 850-2 단가 기준 넘김 헬퍼 — A00_Common/line_stack_basis.ts · common_util_formula_doc_cover.ts 를 트랜스파일해 Node 로 돌림.
* stdin = {저장: 기준 | null, 저장문서: 문서, 지금: [문서]} · stdout = 지금 문서마다 basisNow */
const fs = require("fs");
const path = require("path");
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
const cache = new Map();
function load(at) {
if (cache.has(at)) return cache.get(at);
const js = ts.transpileModule(fs.readFileSync(at, "utf8"), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText;
const box = { exports: {} };
cache.set(at, box.exports);
const need = (p) =>
p.startsWith(".") ? load(path.resolve(path.dirname(at), `${p}.ts`)) : require(p);
new Function("exports", "module", "require", js)(box.exports, box, need);
return box.exports;
}
const basis = load(path.join(__dirname, "..", "..", "A00_Common", "line_stack_basis.ts"));
const ask = JSON.parse(fs.readFileSync(0, "utf8"));
const edits = basis.priceEdits(ask.저장문서);
process.stdout.write(
JSON.stringify(ask.지금.map((d) => basis.basisNow(ask.저장 ?? undefined, d, edits) ?? null)),
);