MCPcopy
hub / github.com/nukeop/nuclear / getObjectPreview

Function getObjectPreview

packages/player/src/services/logger.ts:123–143  ·  view source on GitHub ↗
(obj: object)

Source from the content-addressed store, hash-verified

121};
122
123const getObjectPreview = (obj: object): string => {
124 try {
125 const entries = Object.entries(obj)
126 .slice(0, PREVIEW_MAX_ENTRIES)
127 .map(([key, val]) => {
128 if (val === obj) {
129 return `${key}: [circular]`;
130 }
131 const valStr =
132 typeof val === 'string'
133 ? val.slice(0, PREVIEW_MAX_VALUE_LENGTH)
134 : typeof val === 'object'
135 ? '[object]'
136 : String(val);
137 return `${key}: ${valStr}`;
138 });
139 return entries.join(', ');
140 } catch {
141 return '[unable to preview]';
142 }
143};

Callers 1

formatLogValueFunction · 0.85

Calls 1

entriesMethod · 0.80

Tested by

no test coverage detected