MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / stableJson

Function stableJson

packages/core/src/debug/debugController.ts:162–190  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

160}
161
162function stableJson(value: unknown): string {
163 if (value === null || typeof value !== "object") {
164 return JSON.stringify(value);
165 }
166 if (Array.isArray(value)) {
167 let out = "[";
168 for (let i = 0; i < value.length; i++) {
169 if (i > 0) out += ",";
170 const item = value[i];
171 out += stableJson(item === undefined ? null : item);
172 }
173 out += "]";
174 return out;
175 }
176
177 const obj = value as Record<string, unknown>;
178 const keys = Object.keys(obj).sort();
179 let out = "{";
180 let first = true;
181 for (const key of keys) {
182 const v = obj[key];
183 if (v === undefined) continue;
184 if (!first) out += ",";
185 first = false;
186 out += `${JSON.stringify(key)}:${stableJson(v)}`;
187 }
188 out += "}";
189 return out;
190}
191
192/**
193 * Debug backend interface for engine communication.

Callers 1

exportBundleBytesFunction · 0.70

Calls 1

keysMethod · 0.65

Tested by

no test coverage detected