@scalar/api-client
Version:
the open source API testing client
19 lines (18 loc) • 489 B
JavaScript
const n = (a, i = {}) => {
const { prefix: $ = "" } = i, e = /* @__PURE__ */ new WeakMap(), s = (r, c = "") => {
if (typeof r != "object" || r === null)
return r;
if (e.has(r))
return { $ref: `#${$}${e.get(r)}` };
if (e.set(r, c), Array.isArray(r))
return r.map((t, f) => s(t, `${c}/${f}`));
const u = {};
for (const [t, f] of Object.entries(r))
u[t] = s(f, `${c}/${t}`);
return u;
};
return s(a);
};
export {
n as removeCircular
};