2026-08-16 22:04:11 +03:00

7 lines
416 B
TypeScript

import { LayoutCache, layoutDag } from "../src/index.js";
const graph = { nodes: [{ id: "cause", width: 120, height: 40 }, { id: "effect", width: 120, height: 40 }], edges: [{ source: "cause", target: "effect" }] };
const cache = new LayoutCache<string, ReturnType<typeof layoutDag>>(4);
export const cachedLayout = cache.getOrCompute("cause-effect", () => layoutDag(graph));
export const cacheStats = cache.stats;