MCPcopy Create free account
hub / github.com/Noumena-Network/code / sliceFit

Function sliceFit

src/ink/wrap-text.ts:23–26  ·  view source on GitHub ↗
(text: string, start: number, end: number)

Source from the content-addressed store, hash-verified

21// sliceAnsi may include a boundary-spanning wide char (e.g. CJK at position
22// end-1 with width 2 overshoots by 1). Retry with a tighter bound once.
23function sliceFit(text: string, start: number, end: number): string {
24 const s = sliceAnsi(text, start, end)
25 return stringWidth(s) > end - start ? sliceAnsi(text, start, end - 1) : s
26}
27
28function truncate(
29 text: string,

Callers 1

truncateFunction · 0.85

Calls 1

sliceAnsiFunction · 0.85

Tested by

no test coverage detected