mcporter/tests/fixtures/ansi.ts
2025-11-18 05:32:45 +00:00

19 lines
386 B
TypeScript

export function stripAnsi(value: string): string {
let result = '';
let index = 0;
while (index < value.length) {
const char = value[index];
if (char === '\u001B') {
index += 1;
while (index < value.length && value[index] !== 'm') {
index += 1;
}
index += 1;
continue;
}
result += char;
index += 1;
}
return result;
}