MCPcopy Create free account
hub / github.com/anomalyco/opencode / normalizeText

Function normalizeText

packages/tui/src/attention.ts:69–76  ·  view source on GitHub ↗
(input: string | undefined, fallback: string, limit: number)

Source from the content-addressed store, hash-verified

67}
68
69function normalizeText(input: string | undefined, fallback: string, limit: number) {
70 const text = stripAnsi(input ?? "")
71 .replace(/[ \t]*[\r\n]+[ \t]*/g, " ")
72 .replace(/[\u0000-\u0009\u000B\u000C\u000E-\u001F\u007F-\u009F]/g, "")
73 .trim()
74 const normalized = text.length ? text : fallback
75 return Array.from(normalized).slice(0, limit).join("")
76}
77
78function clampVolume(volume: number) {
79 if (!Number.isFinite(volume)) return 0

Callers 1

notifyFunction · 0.85

Calls 1

fromMethod · 0.45

Tested by

no test coverage detected