MCPcopy Index your code
hub / github.com/simstudioai/sim / truncateStringLine

Function truncateStringLine

packages/emcn/src/components/code/code.tsx:315–327  ·  view source on GitHub ↗

* Truncates a long string value in a JSON line for collapsed display. * * @param line - The original line content * @returns Truncated line with ellipsis

(line: string)

Source from the content-addressed store, hash-verified

313 * @returns Truncated line with ellipsis
314 */
315function truncateStringLine(line: string): string {
316 const colonIdx = line.indexOf('":')
317 if (colonIdx === -1) return line
318
319 const valueStart = line.indexOf('"', colonIdx + 1)
320 if (valueStart === -1) return line
321
322 const prefix = line.slice(0, valueStart + 1)
323 const suffix = line.charCodeAt(line.length - 1) === 44 /* ',' */ ? '",' : '"'
324 const truncated = line.slice(valueStart + 1, valueStart + 1 + MAX_TRUNCATED_STRING_LENGTH)
325
326 return `${prefix}${truncated}...${suffix}`
327}
328
329/**
330 * Custom hook for managing JSON collapse state and computations.

Callers 1

code.tsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected