- 층 셈(파이썬 · TS 짝 master_doc_cover ↔ common_util_formula_doc_cover): merge 에 작업량 칸 단위(merge_work) · merge_layers · layeredCover · upper_of · sources · prune(…, upper) · prune_work_layer - prune_doc(…, upper): 작업량 · 굳은 기계를 얹고 정본 셈 · 문서 안(선택 목록 · 따옴표 글 · 변수 기호)에 든 열쇠 고침은 안 불려도 남김 - SK: 셈 cover = ① 위덮음 + ② 문서 기계덮음(사본 셈 · 빈틈 · 연결 기록) · 프로젝트 층 밖 = 지금 기초 것 · 저장 때 굳음 · 굳히기 = 그때 기초 것 · derive 는 기초 덮음을 떼고 복사 · 읽기 답에 위덮음 - M01 저장: 기계덮음 검사 · 정본과 같은 칸 지움 · 빌더 결과와 셈 칸이 다르면 손고침 표지 - 빌더: 저장본 기계덮음 이어받음 · 손고침 문서 저장본 그대로 + 목록 - 시험 test_848_1_cover_layers(거울 36 경우 · M01 · SK · 굳힘 · A→B) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
/* 848-1 겹쳐 덮는 층 거울 헬퍼 — common_util_formula_doc_cover.ts 를 그 자리에서 트랜스파일해 Node 로 돌림.
|
|
* stdin = {경우: [{위, 나, 기본}]}
|
|
* stdout = {답: [{합침: mergeCover, 층: mergeLayers, 정리: prune, 위값: upperOf, 출처: sourcesOf}]} */
|
|
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 cover = load(path.join(__dirname, "..", "..", "common_util", "common_util_formula_doc_cover.ts"));
|
|
|
|
const input = JSON.parse(fs.readFileSync(0, "utf8"));
|
|
const out = { 답: [] };
|
|
for (const one of input.경우 || []) {
|
|
const up = one.위 ?? null;
|
|
const me = one.나 ?? null;
|
|
out.답.push({
|
|
합침: cover.mergeCover(up, me),
|
|
층: cover.mergeLayers(up ? { K: up } : null, me ? { K: me } : null),
|
|
정리: me ? cover.prune(me, one.기본, up) : null,
|
|
위값: cover.upperOf(one.기본, up),
|
|
출처: cover.sourcesOf(up, me),
|
|
});
|
|
}
|
|
process.stdout.write(JSON.stringify(out));
|