implement naive regex for stripping ANSI escape codes

This commit is contained in:
Louis-Ladd 2025-12-07 22:32:45 -07:00
parent 0bda70bac3
commit dbce8020f1

View File

@ -5,7 +5,6 @@
*/ */
import Operation from "../Operation.mjs"; import Operation from "../Operation.mjs";
import OperationError from "../errors/OperationError.mjs";
/** /**
* Remove ANSI Escape Codes operation * Remove ANSI Escape Codes operation
@ -33,7 +32,8 @@ class RemoveANSIEscapeCodes extends Operation {
* @returns {string} * @returns {string}
*/ */
run(input, args) { run(input, args) {
throw new OperationError("Test"); const ansiRegex = /(?:\x1B|\\x1b|\\033|\\u001b)\[[0-?]*[ -/]*[@-~]/g;
return input.replace(ansiRegex, "");
} }
} }