MCPcopy Create free account
hub / github.com/callstack/agent-device / sliceVisibleColumns

Function sliceVisibleColumns

src/replay/test/progress.ts:302–318  ·  view source on GitHub ↗
(value: string, columns: number)

Source from the content-addressed store, hash-verified

300}
301
302function sliceVisibleColumns(value: string, columns: number): string {
303 if (columns <= 0) return '';
304 let visibleColumns = 0;
305 let output = '';
306 for (let index = 0; index < value.length && visibleColumns < columns; ) {
307 const ansi = readAnsiEscapeAt(value, index);
308 if (ansi) {
309 output += ansi;
310 index += ansi.length;
311 continue;
312 }
313 output += value[index];
314 index += 1;
315 visibleColumns += 1;
316 }
317 return output;
318}
319
320function readAnsiEscapeAt(value: string, index: number): string | null {
321 if (!value.startsWith(ANSI_ESCAPE_PREFIX, index)) return null;

Callers 1

trimToColumnsFunction · 0.85

Calls 1

readAnsiEscapeAtFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…