UNPKG

mermaid

Version:

Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.

42 lines (39 loc) • 1.04 kB
import { __name } from "./chunk-Y2CYZVJY.mjs"; // src/diagrams/common/sanitizeMetadata.ts function stripPrototypeKeys(value) { const copies = /* @__PURE__ */ new WeakMap(); function sanitize(value2) { if (value2 === null || typeof value2 !== "object") { return value2; } const existing = copies.get(value2); if (existing !== void 0) { return existing; } if (Array.isArray(value2)) { const clean2 = new Array(value2.length); copies.set(value2, clean2); value2.forEach((entry, index) => { clean2[index] = sanitize(entry); }); return clean2; } const clean = {}; copies.set(value2, clean); for (const key of Object.keys(value2)) { if (key === "__proto__" || key === "constructor" || key === "prototype") { continue; } clean[key] = sanitize(value2[key]); } return clean; } __name(sanitize, "sanitize"); return sanitize(value); } __name(stripPrototypeKeys, "stripPrototypeKeys"); export { stripPrototypeKeys };