MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / serialize

Function serialize

test/jest-config.ts:144–159  ·  view source on GitHub ↗
(x: any)

Source from the content-addressed store, hash-verified

142}
143
144function serialize(x: any): string {
145 if (Array.isArray(x)) {
146 return `[${x.map((y) => recursiveSerialize(y)).join(', ')}]`;
147 }
148 if (x === null) return 'null';
149 if (x === undefined) return 'undefined';
150 if (typeof x === 'object') {
151 return `[${Object.entries(x)
152 .map(([key, value]) => '"' + key + '": ' + recursiveSerialize(value))
153 .join(', ')}]`;
154 }
155 if (typeof x === 'string') {
156 return `"${x}"`;
157 }
158 return x.toString();
159}
160
161global.console = new EpsilConsole(
162 process.stdout,

Callers 4

logMethod · 0.70
errorMethod · 0.70
assertMethod · 0.70
recursiveSerializeFunction · 0.70

Calls 4

recursiveSerializeFunction · 0.85
mapMethod · 0.65
entriesMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected