MCPcopy Create free account
hub / github.com/DSGWJQ/Feagent / stringify

Function stringify

web/src/features/workflows/utils/workflowDiff.ts:26–41  ·  view source on GitHub ↗
(v: unknown)

Source from the content-addressed store, hash-verified

24function safeStableStringify(value: unknown): string {
25 const seen = new WeakSet<object>();
26 const stringify = (v: unknown): unknown => {
27 if (v && typeof v === 'object') {
28 if (seen.has(v as object)) return '[Circular]';
29 seen.add(v as object);
30 if (Array.isArray(v)) return v.map(stringify);
31 const obj = v as Record<string, unknown>;
32 const out: Record<string, unknown> = {};
33 Object.keys(obj)
34 .sort()
35 .forEach((k) => {
36 out[k] = stringify(obj[k]);
37 });
38 return out;
39 }
40 return v;
41 };
42 try {
43 return JSON.stringify(stringify(value));
44 } catch {

Callers 1

safeStableStringifyFunction · 0.85

Calls 3

mapMethod · 0.80
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected