mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-08-28 08:35:57 +00:00
14 lines
339 B
TypeScript
14 lines
339 B
TypeScript
export function stripAnsi(text: string): string {
|
|
return text
|
|
.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "")
|
|
.replace(/\x1b\][0-9;]*(?:\x07|\x1b\\)/g, "")
|
|
.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g, "");
|
|
}
|
|
|
|
export function stripAnsiFast(text: string): string {
|
|
if (!text.includes("\x1b")) {
|
|
return text;
|
|
}
|
|
return stripAnsi(text);
|
|
}
|