plain(text: string): string
The text with its colour taken off — what the terminal would show on a screen with none.
Split on the escape rather than matched with a pattern: a regular expression for this needs a literal control character in it, which every linter with an opinion about control characters objects to, and it would be slower besides.
import { plain } from './terminal.ts'; plain(`${String.fromCharCode(27)}[33mhi${String.fromCharCode(27)}[0m`); // 'hi'