* Applies a final serialized-size cap after recursive normalization.
(value: unknown)
| 188 | * Applies a final serialized-size cap after recursive normalization. |
| 189 | */ |
| 190 | function capNormalizedValue(value: unknown): unknown { |
| 191 | if (value === null || value === undefined) { |
| 192 | return value |
| 193 | } |
| 194 | |
| 195 | const serialized = safeConsoleStringify(value) |
| 196 | const serializedBytes = getByteLength(serialized) |
| 197 | |
| 198 | if (serializedBytes <= TERMINAL_CONSOLE_LIMITS.MAX_SERIALIZED_BYTES) { |
| 199 | return value |
| 200 | } |
| 201 | |
| 202 | return { |
| 203 | __simTruncated: true, |
| 204 | __simByteLength: serializedBytes, |
| 205 | __simPreview: truncateString(serialized, TERMINAL_CONSOLE_LIMITS.MAX_SERIALIZED_PREVIEW_LENGTH), |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Normalizes terminal input data before it is stored. |
no test coverage detected