MCPcopy Create free account
hub / github.com/FIND-Lab/AgentWard / clampText

Function clampText

index.ts:43–49  ·  view source on GitHub ↗
(text: string, maxChars: number)

Source from the content-addressed store, hash-verified

41}
42
43function clampText(text: string, maxChars: number): string {
44 if (maxChars <= 0) return "";
45 const normalized = text ?? "";
46 if (normalized.length <= maxChars) return normalized;
47 if (maxChars <= 1) return normalized.slice(0, maxChars);
48 return normalized.slice(0, maxChars - 1) + "…";
49}
50
51function stableStringify(value: unknown): string {
52 if (value === null || value === undefined) return String(value);

Callers 1

registerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected